PHP MySQL ebook
February 12, 2011 – 4:57 pm | No Comment

Hey everyone!!
With this section I hope to share with you resources which I have tried and valued
So you’re new to PHP and want to learn from scratch. Well I was in your position not too …

Read the full story »
SEO Tutorials

Need help with Search Engine Optimisation? This is the place to look for the latest tips and hints with the advice we offer. Keep an eye out here for the latest posts.

PHP Tutorials

Learn how to code with PHP to achieve your goal. In here I aim to show and teach you about little tips and tricks that should enhance your coding abilities

Flash Tutorials

Learn how to use Adobe Flash for your own purposes. Little tips and hints to help you along

Website Development

In here I aim to help you with developing your website from scratch. Come here for various tips and pieces of advice to help you build and improve your website.

Home » PHP Tutorials

mysql_num_rows()

Submitted by on July 29, 2007 – 3:19 pmNo Comment

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

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. $link = mysql_connect("localhost", "root", "");//conect to db server
  2. mysql_select_db("haco", $link);//select db
  3. $result = mysql_query("SELECT COUNT(*) FROM projects", $link); //select the table
  4. echo "total_rows=$result"; //echo number of rows
  5. ?>

VN:F [1.9.13_1145]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.13_1145]
Rating: 0 (from 0 votes)

Popularity: unranked [?]

Leave a comment!

Add your comment below, or trackback from your own site. You can also subscribe to these comments via RSS.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

This is a Gravatar-enabled weblog. To get your own globally-recognized-avatar, please register at Gravatar.