The place that has your tutorials

mysql_num_rows()

This is a MySQL function that allows you to find out how many rows there are in a specific table.

It requires only one parameter which tells it whats the MySQL query.

I found it extremely useful when making a flash and MySQL and PHP driven site.

PHP:
  1. <?php
  2. $link = mysql_connect("localhost", "root", "");//conect to db server
  3. mysql_select_db("haco", $link);//select db
  4.  
  5. $result = mysql_query("SELECT * FROM projects", $link); //select the table
  6. $num_rows = mysql_num_rows($result); //set variable
  7.  
  8. echo "total_rows=$num_rows"; //echo number of rows
  9.  
  10. ?>

i hope you find it just as useful to you just like when i first found it.

However if you are looking for executing queries fast I would use:

PHP:
  1. <?php
  2. $link = mysql_connect("localhost", "root", "");//conect to db server
  3. mysql_select_db("haco", $link);//select db
  4. $result = mysql_query("SELECT COUNT(*) FROM projects", $link); //select the table
  5. echo "total_rows=$result"; //echo number of rows
  6. ?>

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • Netvouz
  • DZone
  • ThisNext
  • MisterWong
  • Wists

Leave a Reply