Re: PHP/MySQL & Control Structures -> if (mysql_query())

From: Date: Wed, 21 Mar 2001 06:09:52 +0000
Subject: Re: PHP/MySQL & Control Structures -> if (mysql_query())
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-44886@lists.php.net to get a copy of this message
On 21-Mar-01 Mike Gifford wrote: > Hi David, > > I counted the number of rows using mysql_numrows(), but I've been told that > count() is way faster. Unfortunately, I can't seem to get count working.. > Any > ideas? > > <?php > echo mysql_numrows(mysql_query("select * FROM phPetition",$db)); > > // This should be faster, but doesn't seem to work > // echo count(mysql_query("select * FROM phPetition",$db)); > ?> > ;) $result= mysql_query("select count(*) as cnt FROM phPetition",$db)); if ($result) { $row = mysql_fetch_object($result); echo 'count: ', $row->cnt, '<br>'; }  Regards, -- Don Read dread@texas.net -- If you are going to sin, sin against God, not the bureaucracy. God will forgive you but the bureaucrats won't.

« previous php.general (#44886) next »