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 abstraction php?

0 Answers  


How to initiate a session in php?

0 Answers  


What is list in PHP?

0 Answers  


Why is php used?

0 Answers  


Explain the difference between isset() and empty()?

0 Answers  






Php code to find whether a number armstrong or not?

0 Answers  


What is meant by ‘passing the variable by value and reference' in php?

0 Answers  


How is it possible to set an infinite execution time for php script?

0 Answers  


Explain what is the use of "echo" in php?

0 Answers  


when we select some checkboxes and we went for next page if we came back to prevoius page the selcted checkboxe should be checked

2 Answers  


How can I embed a java programme in PHP file and what changes have to be done in PHP.ini file?

1 Answers   Sify, Small Biz Express,


How can I reset an array in PHP?

4 Answers   Rushmore Consultancy, TCS,


Categories