Re: Count

From: Date: Thu, 30 Aug 2001 10:52:52 +0000
Subject: Re: Count
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-65209@lists.php.net to get a copy of this message
can do another way $sql = "select count(fieldname) from Products"; $result=mysql_query($sql); $myrow=$mysql_fetch_row($result); $countrows = $myrow[0]; ( or might be $myrow[1] check out) will do the job /sagar ----- Original Message ----- From: David Robley <huntsman@flinders.edu.au> To: Kevin P <kevin.pottie@odellwebdesign.com>; <php-general@lists.php.net> Sent: Thursday, August 30, 2001 6:06 AM Subject: Re: [PHP] Count > On Thu, 30 Aug 2001 08:16, Kevin P wrote: > > Hi > > I have counted some rows in MySQL and I need to know how to pull out > > the number of rows. > > "SELECT COUNT(*) AS myCount FROM Products" > > > > Thanks > > Kevin > > $query = "SELECT COUNT(*) AS myCount FROM Products"; > $result = mysql_db_query($database, $query); > $row = mysql_fetch_array($result); > extract($row); > echo $myCount; > > might do the trick; unless I've left a syntax error in there :-) > > -- > David Robley Techno-JoaT, Web Maintainer, Mail List Admin, etc > CENTRE FOR INJURY STUDIES Flinders University, SOUTH AUSTRALIA > > I'm so broke, I can't even pay attention. > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net > >

« previous php.general (#65209) next »