• PHP Video Tutorials

PHP - Function MySQLi Affected Rows



Syntax

int mysqli_affected_rows ([ resource $link_identifier = NULL ] )

Definition and Usage

It returns the number of affected rows in the previous SELECT, INSERT, UPDATE, REPLACE, or DELETE query.

Return Values

An integer > 0 indicates the number of rows affected.0 indicates that no records were affected. -1 indicates that the query returned an error

Parameters

Sr. No Parameters & Description
1

connection

It specifies the number of connections to use in php

Example of mysqli_affected_rows() as shown below −

<?php
   $input = mysqli_connect("host_name","user_name","pass_id","db_name");
   
   if (mysqli_connect_errno($input)){
      echo "Failed to connect to MySQL: " . mysqli_connect_error();
   }
   
   mysqli_query($input,"SELECT * FROM emp");
   echo "Affected rows: " . mysqli_affected_rows($input);
   
   mysqli_close($input);
?>
php_function_reference.htm
Advertisements