PHP mysqli_affected_rows() Function
Example
Output the number of affected rows from different queries:
" ; mysqli_query ( $con , "DELETE FROM websites WHERE alexa>1000" ); echo "Affected rows: " . mysqli_affected_rows ( $con ); mysqli_close ( $con ); ?>Definition and Usage
The mysqli_affected_rows() function returns the number of affected rows from the previous MySQL operation (SELECT, INSERT, UPDATE, REPLACE, DELETE).
Syntax
mysqli_affected_rows(
connection
)
;
| Parameters | Description |
|---|---|
| connection | Required. Specifies the MySQL connection to use. |
Technical Details
| Return Value: | An integer greater than 0 indicates the number of affected rows. 0 indicates no affected records. -1 indicates that the query returned an error. |
|---|---|
| PHP Version: | 5+ |
PHP MySQLi Reference Manual