NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming > Webmaster Tutorials
Reload this Page mysql_num_rows()

Webmaster Tutorials Instructional webmaster-related how-to's and tutorials.

Advanced Search
0 members in live chat ~  


Closed Thread
 
LinkBack Thread Tools
Old 03-04-2006, 01:27 PM THREAD STARTER               #1 (permalink)
NamePros Regular
 
asgsoft's Avatar
Join Date: Sep 2005
Location: At Home
Posts: 881
asgsoft is a glorious beacon of lightasgsoft is a glorious beacon of lightasgsoft is a glorious beacon of lightasgsoft is a glorious beacon of lightasgsoft is a glorious beacon of lightasgsoft is a glorious beacon of lightasgsoft is a glorious beacon of lightasgsoft is a glorious beacon of light
 



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
????: NamePros.com http://www.namepros.com/webmaster-tutorials/173485-mysql_num_rows.html

$result mysql_query("SELECT COUNT(*) FROM projects"$link); //select the table
????: NamePros.com http://www.namepros.com/showthread.php?t=173485

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

?>
That was a suggestion by NuPagady
Last edited by asgsoft; 03-04-2006 at 01:48 PM. Reason: adding an extra suggestion by NuPagady
asgsoft is offline  
Old 03-04-2006, 01:45 PM   #2 (permalink)
NamePros Regular
 
NuPagady's Avatar
Join Date: Jul 2005
Posts: 483
NuPagady is on a distinguished road
 



Yes, that would work. However, I think "SELECT COUNT(*) FROM projects" query would work faster.
NuPagady is offline  
Old 03-04-2006, 01:46 PM THREAD STARTER               #3 (permalink)
NamePros Regular
 
asgsoft's Avatar
Join Date: Sep 2005
Location: At Home
Posts: 881
asgsoft is a glorious beacon of lightasgsoft is a glorious beacon of lightasgsoft is a glorious beacon of lightasgsoft is a glorious beacon of lightasgsoft is a glorious beacon of lightasgsoft is a glorious beacon of lightasgsoft is a glorious beacon of lightasgsoft is a glorious beacon of light
 



thanks for the suggestion. I will add it too.
asgsoft is offline  
Old 03-06-2006, 03:46 AM   #4 (permalink)
NamePros Member
 
J4m!3's Avatar
Join Date: Oct 2005
Location: Clevedon, UK
Posts: 198
J4m!3 will become famous soon enoughJ4m!3 will become famous soon enough
 



Got to agree
J4m!3 is offline  
Old 03-06-2006, 04:13 AM   #5 (permalink)
Account Suspended
 
JuggernautH's Avatar
Join Date: Dec 2005
Location: ../home/mysite
Posts: 3,565
JuggernautH has much to be proud ofJuggernautH has much to be proud ofJuggernautH has much to be proud ofJuggernautH has much to be proud ofJuggernautH has much to be proud ofJuggernautH has much to be proud ofJuggernautH has much to be proud ofJuggernautH has much to be proud ofJuggernautH has much to be proud ofJuggernautH has much to be proud of
 


Cancer Child Abuse
Thnx for the helpfull information, i used to code php and that stuff before, but i havent done so in about 1.5 years
JuggernautH is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


 
All times are GMT -7. The time now is 12:57 AM.

Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger