PHP – Get the number of affected rows by the last INSERT, UPDATE, REPLACE or DELETE query.
The given PHP example helps you to get the number of affected rows by the last INSERT, UPDATE,
REPLACE or DELETE query associated with link_identifier.
$server = "localhost";
$username = "root";
$password = "";
$database = "";
$conn = mysql_connect($server, $username, $password) or die("Couldn't connect to MySQL" . mysql_error());
$query = "UPDATE mytable SET title = 'test' WHERE status = 'Y'";
$result = mysql_query($query);
print "Total row updated: ".mysql_affected_rows(); // return -1 if last query is failed.