RE: [PHP] RE: Record Counts

From: Date: Tue, 24 Feb 2004 11:11:45 +0000
Subject: RE: [PHP] RE: Record Counts
Groups: php.general 
Request: Send a blank email to php-general+get-178665@lists.php.net to get a copy of this message
[snip] I did RTFM...I always RTFM first. That was the example in the F Book!. Mark Roberts, Roberts Computing Systems Webmaster Services $29.50/mo $reccount = @mysql_query("select count(*) from mytable where user = 'testuser'); I try this from mysql and get the correct response ( 1 ). However, when I put this in an php script, $reccount returns a value of 'Resource id #5'. [/snip] Perhaps you did not UTFM or CTFM. But I digress... $recount at this point is only a handle or resource, you have to do something with it. You need to change your query a little though... $reccount = @mysql_query("select count(*) AS recordCount from mytable where user = 'testuser'); recordCount gives you another handle. Now you can do ... $arrRecCount = mysql_fetch_array($reccount); echo $arrRecCount['recordCount']; or you can do it differently $getUser = @mysql_query("select * from mytable where user = 'testuser'); $recCount = mysql_num_rows($getUser); echo $recCount; HTH!

« previous php.general (#178665) next »