You are here : phpmysqlimysqli_affected_rows

mysqli_affected_rows() - mysqli

The mysqli_affected_rows() function returns the number of affected rows in the previous 
SELECT, INSERT, UPDATE, REPLACE, or DELETE query.


Syntax

mysqli_affected_rows(connection);


Example

<?php
$con=mysqli_connect("localhost","my_user","my_password","my_db");
if (mysqli_connect_errno())
  {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }

// Perform queries and print out affected rows
mysqli_query($con,"SELECT * FROM Persons");
echo "Affected rows: " . mysqli_affected_rows($con);

mysqli_query($con,"DELETE FROM Persons WHERE Age>32");
echo "Affected rows: " . mysqli_affected_rows($con);

mysqli_close($con);
?> 


Output / Return Value


Limitations


Alternatives / See Also

PDO and mysql_affected_rows()


Reference