PHP functions for MySql : mysqli_num_rows()

The mysqli_num_rows() function returns the number of rows in a result set. The syntax is :
mysqli_num_rows( $result_set_identifier )
Where the $result_set_identifier is nothing but the returned object by mysqli_query() function.

Example :
<?php

  $server = "localhost";
  $username = "root";
  $password = "";
  $dbName = "mydb";

  $connection = mysqli_connect($server, $username, $password, $dbName);

  $sql = "SELECT * from employee";
  $result = mysqli_query($connection, $sql);
  $rowcount = mysqli_num_rows($result);

  echo "The number of Rows is : " . $rowcount;

  mysqli_close($connection);

?>
Output :

The number of Rows is : 6


Next Topic :