Current location: Hot Scripts Forums » Programming Languages » PHP » Returning number of results found


Returning number of results found

Reply
  #1 (permalink)  
Old 07-22-05, 07:33 PM
DetroitGuy DetroitGuy is offline
Newbie Coder
 
Join Date: Jun 2005
Posts: 83
Thanks: 0
Thanked 0 Times in 0 Posts
Returning number of results found

Hey guys. I am working on a search engine and having a little trouble.

How do you return the number of results found when you query a database?

For instance:

Quote:
while($qry = mysql_fetch_array($result))
{
That will of course print the results however I choose to format them, but is there a way to extract how many results were found?

Thanks!
Reply With Quote
  #2 (permalink)  
Old 07-22-05, 08:45 PM
the_mole001's Avatar
the_mole001 the_mole001 is offline
Newbie Coder
 
Join Date: Feb 2004
Location: Australia
Posts: 96
Thanks: 0
Thanked 0 Times in 0 Posts
PHP Code:

echo mysql_num_rows($result); 

__________________
Current Project: GGAC Website
Project Link: http://peter.5gigs.com/
Reply With Quote
  #3 (permalink)  
Old 07-22-05, 08:50 PM
Acecool's Avatar
Acecool Acecool is offline
Aspiring Coder
 
Join Date: Nov 2003
Posts: 506
Thanks: 0
Thanked 0 Times in 0 Posts
http://us2.php.net/mysql_affected_rows / for update, delete etc..

mysql_num_rows is the right one for you

or
you can set a variable to count as it outputs..

$i++;
__________________
Check Acecoolco.com for PHP Tutorials, and other tuts
If you plan on contacting me, please read this: Legal Terms & Conditions

Last edited by Acecool; 07-22-05 at 08:52 PM. Reason: update
Reply With Quote
  #4 (permalink)  
Old 07-22-05, 08:54 PM
DetroitGuy DetroitGuy is offline
Newbie Coder
 
Join Date: Jun 2005
Posts: 83
Thanks: 0
Thanked 0 Times in 0 Posts
Trying that only returns 10.

I should mention that I am creating a paging system to display results which limits the page to 10 results per page.

I believe the solution lies in SQL_CALC_FOUND_ROWS.

I seem to be having a problem returning found_rows(); however. I'll work on it some more.

Yep. Got it working. Thanks you the advice however. It is always appreciated.

Last edited by DetroitGuy; 07-22-05 at 09:30 PM.
Reply With Quote
Reply

Bookmarks


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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Perfect number... Argo_Jeude C/C++ 1 07-14-05 02:35 PM
PHP, MySQL Beginner... Help Needed Displaying Results db3db3 PHP 1 05-12-04 01:24 AM
Show results if number in db perleo PHP 3 03-07-04 10:34 AM


All times are GMT -5. The time now is 06:59 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.