How can we find the number of rows in a result set using PHP?

Answers were Sorted based on User's Feedback



How can we find the number of rows in a result set using PHP?..

Answer / rajan vardawaj

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”;

Is This Answer Correct ?    14 Yes 0 No

How can we find the number of rows in a result set using PHP?..

Answer / sunil kumar

<?php //first establish connection with database
mysql_connect("localhost","root","");
mysql_select_db("demoprj");
// then write the query suppose our table is tbl_student
$sql_stu="select* from tbl_student";
$res_stu=mysql_query($sql_stu);
$rows_stu=mysql_num_rows($res_stu);
echo"number of rows in tbl_student are=".$rows_stu;
?>

Is This Answer Correct ?    2 Yes 0 No

Post New Answer

More PHP Interview Questions

Is array function in php?

0 Answers  


write a prog using insert,update,delete in this manner as output? name: phno. add button 1.name phno. edit button delete button 2.

0 Answers  


How to find length of an array in php ?

0 Answers  


What is difference between str_replace and substr_replace

1 Answers  


What is the difference between mysqli_fetch_object() and mysqli_fetch_array()?

0 Answers  


Does php need apache?

0 Answers  


How many types of arrays are there in php?

0 Answers  


What is echo in html?

0 Answers  


How to write in a file in php?

0 Answers  


What is MVC structure in Magento?

4 Answers  


What are magic constants in php?

0 Answers  


How I use global variable in another page without using $_GET method?

9 Answers  


Categories