mysqli_affected_rows Gets the number of affected rows in a previous MySQL operation Description mixedmysqli_affected_rows objectlink mysqli_affected_rows returns the number of rows affected by the last INSERT, UPDATE, or DELETE query associated with the provided link parameter. If the last query was invalid, this function will return -1. When deleting the entire contents of a table (i.e. 'DELETE FROM foo'), this function will not return the number of rows that were actually deleted. The mysqli_affected_rows function only works with queries which modify a table. In order to return the number of rows from a SELECT query, use the mysqli_num_rows function instead. Delete-Query Procedural style: ]]> Object oriented style: query("DELETE FROM mytable WHERE id < 10"); printf ("Records deleted: %2d\n", $mysql->affected_rows()); /* without a where clause in a delete statement, it should return 0 */ $mysql->query("DELETE FROM mytable"); printf ("Records deleted: %2d\n", $mysql->affected_rows()); /* close connection */ $mysql->close(); ?> ]]> The above examples would produce the following output: Update-Query Procedural style: ]]> Object oriented style: query("UPDATE mytable SET used=1 WHERE id < 10"); printf ("Updated records: %d\n", $mysql->affected_rows($link)); /* close connection */ $mysql->close($link); ?> ]]> The above examples would produce the following output: See also: mysqli_num_rows, mysqli_info.