User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the MySQL section within the Web Development category of DaniWeb, a massive community of 402,525 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,487 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our MySQL advertiser: Programming Forums
Views: 2812 | Replies: 4
Reply
Join Date: Mar 2007
Location: georgia
Posts: 55
Reputation: hunkychop is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 4
hunkychop's Avatar
hunkychop hunkychop is offline Offline
Junior Poster in Training

Help Return number of rows in table

  #1  
Apr 21st, 2007
does anybody know a mysql query that i can use in my php document that will return the number of rows their are in a table?

thanks, i cant find it in the MySQL mannual
Last edited by hunkychop : Apr 21st, 2007 at 11:45 am.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: May 2006
Location: New Jersey
Posts: 1,422
Reputation: stymiee is on a distinguished road 
Rep Power: 5
Solved Threads: 34
Moderator
Staff Writer
stymiee's Avatar
stymiee stymiee is offline Offline
He's No Good To Me Dead

Re: Return number of rows in table

  #2  
Apr 22nd, 2007
John Conde
Brainyminds | Merchant Account Services | I Love Code
IT'S HERE: Merchant Accounts 101 Everything you need to know about merchant accounts!
Reply With Quote  
Join Date: Mar 2007
Location: georgia
Posts: 55
Reputation: hunkychop is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 4
hunkychop's Avatar
hunkychop hunkychop is offline Offline
Junior Poster in Training

Re: Return number of rows in table

  #3  
Apr 22nd, 2007
how whould i use that to return the result in php. do i just use
$result = mysql_num_rows(info);
or is there more to it
Reply With Quote  
Join Date: May 2006
Location: New Jersey
Posts: 1,422
Reputation: stymiee is on a distinguished road 
Rep Power: 5
Solved Threads: 34
Moderator
Staff Writer
stymiee's Avatar
stymiee stymiee is offline Offline
He's No Good To Me Dead

Re: Return number of rows in table

  #4  
Apr 22nd, 2007
  1. <?php
  2.  
  3. $link = mysql_connect("localhost", "mysql_user", "mysql_password");
  4. mysql_select_db("database", $link);
  5.  
  6. $result = mysql_query("SELECT * FROM table1", $link);
  7. $num_rows = mysql_num_rows($result);
  8.  
  9. echo "$num_rows Rows";
  10.  
  11. ?>
Last edited by stymiee : Apr 22nd, 2007 at 9:27 pm.
John Conde
Brainyminds | Merchant Account Services | I Love Code
IT'S HERE: Merchant Accounts 101 Everything you need to know about merchant accounts!
Reply With Quote  
Join Date: Aug 2006
Location: NE PA
Posts: 8
Reputation: dc dalton is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
dc dalton's Avatar
dc dalton dc dalton is offline Offline
Newbie Poster

Re: Return number of rows in table

  #5  
May 2nd, 2007
Actually, not to step on Stymiee's feet but there is a a less memory intensive way to do it.

SELECT COUNT(*) FROM table_name

The result will be the num rows
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb MySQL Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the MySQL Forum

All times are GMT -4. The time now is 7:13 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC