NamePros.Com (http://www.namepros.com/)
-   Webmaster Tutorials (http://www.namepros.com/webmaster-tutorials/)
-   -   mysql_num_rows() (http://www.namepros.com/webmaster-tutorials/173485-mysql_num_rows.html)

asgsoft 03-04-2006 01:27 PM

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 extreemly useful when making a flash and mysql and php driven site.

PHP Code:
<?php
$link
= mysql_connect("localhost", "root", "");//conect to db server
mysql_select_db("haco", $link);//select db

$result = mysql_query("SELECT * FROM projects", $link); //select the table
$num_rows = mysql_num_rows($result); //set variable

echo "total_rows=$num_rows"; //echo number of rows

?>

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 Code:
<?php
$link
= mysql_connect("localhost", "root", "");//conect to db server
mysql_select_db("haco", $link);//select db

$result = mysql_query("SELECT COUNT(*) FROM projects", $link); //select the table

echo "total_rows=$result"; //echo number of rows

?>


That was a suggestion by NuPagady

NuPagady 03-04-2006 01:45 PM

Yes, that would work. However, I think "SELECT COUNT(*) FROM projects" query would work faster.

asgsoft 03-04-2006 01:46 PM

thanks for the suggestion. I will add it too.

J4m!3 03-06-2006 03:46 AM

Got to agree :)

JuggernautH 03-06-2006 04:13 AM

Thnx for the helpfull information, i used to code php and that stuff before, but i havent done so in about 1.5 years :(


All times are GMT -7. The time now is 12:29 PM.
Site Sponsors
\'\' \'\' \'\'
Advertise your business at NamePros

Powered by: vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0