If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > PHP > PHP: how do you get the number of rows returned by a query?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-11-12, 22:58
hello-world hello-world is offline
Registered User
 
Join Date: Dec 2011
Posts: 15
PHP: how do you get the number of rows returned by a query?

I want to know how many rows are in a result. I know you can use mysql_fetch_array iteratively, but can you get the size directly?
Reply With Quote
  #2 (permalink)  
Old 02-12-12, 03:31
healdem healdem is offline
Jaded Developer
 
Join Date: Nov 2004
Location: out on a limb
Posts: 9,262
try boning up on the PHP manual
especially
PHP: Mysql - Manual
__________________
I'd rather be riding my Versys or my Tiger 800 let alone the Norton
Reply With Quote
  #3 (permalink)  
Old 02-12-12, 10:22
sonic10 sonic10 is offline
Registered User
 
Join Date: Apr 2005
Posts: 29
Here is a very basic way.
PHP Code:
<?php

$link 
mysql_connect("localhost""mysql_user""mysql_password");
mysql_select_db("database"$link);

$result mysql_query("SELECT * FROM tbl1"$link);
$num_rows mysql_num_rows($result);

echo 
"$num_rows Rows\n";

?>
__________________
Web Database Software - Build your own php mysql database.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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