---
title: "How can we find the number of rows in a result set using PHP?"  
description: "How can we find the number of rows in a result set using PHP?"  
author: "Anonymous User"  
published: 2011-06-13  
updated: 2020-09-22  
canonical: https://www.mindstick.com/interview/1054/how-can-we-find-the-number-of-rows-in-a-result-set-using-php  
category: "php"  
tags: ["php"]  
reading_time: 1 minute  

---

# How can we find the number of rows in a result set using PHP?

Here is how can you find the number of rows in a result set in PHP:\
\
$result = mysql_query($any_valid_sql, $database_link);\
$num_rows = mysql_num_rows($result);\
echo "$num_rows rows found";

## Answers

### Answer by Anonymous User

Here is how can you find the number of rows in a result set in PHP:\
\
$result = mysql_query($any_valid_sql, $database_link);\
$num_rows = mysql_num_rows($result);\
echo "$num_rows rows found";


---

Original Source: https://www.mindstick.com/interview/1054/how-can-we-find-the-number-of-rows-in-a-result-set-using-php

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
