PHP Mysqli_num_rows () function

PHP

Syntax:
mysqli_num_rows ($result);
Parameters:This function takes one parameter, $result. This is a required parameter and represents the result set returned by the select query in MySQL.Return Value:Returns the number of rows in the result set.Imagine that there is a table in the MySQL database named geek, which is named Geeks. The Geek table is described below. Username Password Geek1 Pass1 Geek2 Pass2 Geek3 Pass3 Geek4 Pass4 The following programs illustrate the mysqli_num_rows() function in PHP. / / Configuring Geeks Database Connection $connection = mysqli_connect ( " localhost " , " root " , "" , "Geeks" ); // Check the connection if (mysqli_connect_errno()) { echo "Database connection failed." ; } // request to get username and password from // geek tables $query = "SELECT Username, Password FROM geek" ; // Run the query and save the result set $result = mysqli_query ( $connection , $query ); if ( $result ) { // returns the number of rows in the table. $row = mysqli_num_rows ( $result ); printf ( " Number of row in the table: " . $row ); // close the result. mysqli_free_result ( $result ); } // Connection closed mysqli_close ( $connection ) ; ?> Exit :
Number of row in the table: 5