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

What is the function func_num_args() used for?

0 Answers  


What is difference between print_r and echo in php?

0 Answers  


Does php have a future?

0 Answers  


What was the old name of php?

0 Answers  


What is the use of "echo" in php?

0 Answers  






Do you know what is the use of rand() in php?

0 Answers  


What is the purpose of the '.myd' file extension? What do thes file contain?

0 Answers  


Which is faster for or foreach php?

0 Answers  


What are the differences between PHP3 and PHP4 versions?

1 Answers  


How can I use the COM components in php?

1 Answers   Covansys, Rushmore Consultancy,


How can image properties be retrieved in php?

0 Answers  


Is rent a variable cost?

0 Answers  


Categories