mysqli_affected_rows(): Returns the number of rows affected by the last INSERT , UPDATE , REPLACE or DELETE query.


Syntax

mysqli_affected_rows(connection)


#example.php

<?php

$con = mysqli_connect("localhost", "root", "", "tutorial");
if (mysqli_connect_errno()) {
    echo "Failed: " . mysqli_connect_error();
    exit();
}
//print out affected rows
mysqli_query($con, "SELECT * FROM Customer");
echo "Affected rows: " . mysqli_affected_rows($con);

mysqli_query($con, "DELETE FROM Customer WHERE customer_id > 10");
echo "Affected rows: " . mysqli_affected_rows($con);
mysqli_close($con);
?>

Run the following code and see the result


Output:

100 rows affected!