Home Sql Mysql-example Php Sql num rows



Php Sql num rows
Posted on: January 20, 2009 at 12:00 AM
In this example, we have created a num_rows.php file in which we executed a query to find the number of rows in the table.

Php Sql num rows

     

This tutorial illustrates how to find number of rows of the table.

In this example, we have created a num_rows.php file in which we executed a query to find the number of rows in the table. We created a connection from database table using mysql_connect("hostName", "userName", "Password"). After the connection created we choose database by mysql_select_db("databaseName", connectionObject) and executed the query by mysql_query("SELECT * FROM tableName"). The number of rows are returned by the mysql_num_rows() method.

 

 

 

Table:emp

 

Source Code of num_rows.php 

<?php
  $link = mysql_connect("localhost""root""root");
  mysql_select_db("test", $link);

  $result = mysql_query("SELECT * FROM emp", $link);
  $num_rows = mysql_num_rows($result);

  echo "<b>$num_rows Rows Found</b>";
?>

 

Output:

Related Tags for Php Sql num rows:
phpsqlmysqlcdatabasequeryfiletabledataioconnectionuserfindpasswordwordexecnumbernameusingthisexecreatetabrowconnectrowsexampleexecutetohostusernamebaseexamwseilhostnameusefrominpassasmososasemehpcutxawhichxampsxecreatedatmyishampleassrdthswavstabablfinpleplndonomo


More Tutorials from this section

Ask Questions?    Discuss: Php Sql num rows  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.