Fri, 17 May 2024


How to get the number of affected rows in previous MySQL operation?

By: Nathalie, NetArt Media
Mon, 22 February 2021

You have to use the mysql_affected_rows() function, for example on delete command, in order to get the numbe rof the delted rows you need to do the following:

<?php
...
mysql_query("DELETE FROM mytable WHERE ID > 1000 ");
echo "Records deleted: ". mysql_affected_rows();
...
?>


Category: PHP Examples
Share this post:



See All Scripts






Subscribe for our newsletter

Receive the latest blog posts direct in your mailbox