mysql_affected_rows()
mysql_affected_rows - Get the number of rows affected in a previous MySQL operation
Example:
$sql = "UPDATE gallery SET order = (order+1) WHERE id_categ = ".$id;
$res = mysql_query($sql);
printf("Affected rows: %d\n", mysql_affected_rows());
Note that mysql_affected_rows()returns you the affected rows updated / deleted from your last request . For instance:
$sql = "UPDATE gallery SET order = (order+1) WHERE id_categ = ".$id;
$res = mysql_query($sql);
$sql = "UPDATE gallery2 SET order = (order+1) WHERE id_categ = ".$id;
$res = mysql_query($sql);
Now if you do:
printf("Affected rows: %d\n", mysql_affected_rows());
It will return the affected rows for the last query, which is gallery2a table query.
Additional Information:
source
share