mysqli_num_rows(): Number of rows present in the result set.

<?Php
require "config.php";// Database connection file.

$query="select * from student ";
if ($result_set = $connection->query($query)) {
echo "Total No. of records :".$result_set->num_rows;
    $result_set->close();
}?>
Total No. of records :35
$result_set->num_rows;
mysqli_num_rows($result_set)
The input parameter $result_set is the output of result set identifier of mysqli_query(), mysqli_store_result() or mysqli_use_result().

The output is number of rows present in the result set.

MySQLI database connection file

Example : Object Oriented Style
<?Php
require "config.php";// Database connection file.

$query="select * from student ";
if ($result_set = $connection->query($query)) {
echo "Total No. of records :".$result_set->num_rows;
    $result_set->close();
}?>
Total No. of records :35

MySQL SELECT Query

Procedural style
<?Php
require "config.php";// Database connection file.

$query="select * from student ";
if ($result_set = mysqli_query($connection,$query)) {
echo "Total No. of records :".mysqli_num_rows($result_set);
    mysqli_free_result($result_set);
}
?>
Total No. of records :35
With bind_param & using variables
$class='Three';
$query="select * from student WHERE class=? ";
$stmt=$connection->prepare($query);
$stmt->bind_param('s', $class); 
$stmt->execute();
$stmt->store_result();
echo "Total No. of records :".$stmt->num_rows;

Checking if matching record is available

$t="SELECT * FROM istudent where mark >90";

$check=$connection->query($t);
if(mysqli_num_rows($check)>0){
// record found 	
}else{
// No record found 	
}

MySQL DUMP of student table

MYSQLI Functions mysqli_fetch_array()
Subhendu Mohapatra — author at plus2net
Subhendu Mohapatra

Author

🎥 Join me live on YouTube

Passionate about coding and teaching, I publish practical tutorials on PHP, Python, JavaScript, SQL, and web development. My goal is to make learning simple, engaging, and project‑oriented with real examples and source code.



Subscribe to our YouTube Channel here



plus2net.com











PHP video Tutorials
We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles Contact us
©2000-2025   plus2net.com   All rights reserved worldwide Privacy Policy Disclaimer