mysql_affected_rows()
int mysql_affected_rows([connection])This function returns the number of rows affected by a
previous SQL statement that modified rows of data for the current
MySQL session. The function returns –1 if the previous statement
failed. It works only after INSERT,
UPDATE, and DELETE statements.
See mysql_num_rows() later in this section
for the number of rows returned by a SELECT
statement. The connection identifier may be given as an argument to
retrieve the number of rows affected by a different connection. Here
is an example:
...
$sql_stmnt = "UPDATE workreq
SET due_date = ADDDATE(due_date, INTERVAL 1 DAY)
WHERE due_date = '2004-07-28'";
mysql_query($sql_stmnt);
$updated = mysql_affected_rows( );
print "Number of Rows Updated: $updated \n";
...This script changes the due dates for all work requests by one day.