RE: [PHP] Counting table fields having specific values

From: Date: Thu, 27 Feb 2003 17:44:10 +0000
Subject: RE: [PHP] Counting table fields having specific values
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-137440@lists.php.net to get a copy of this message
Mike Try ... <? $res = mysql_query('select count(*) from names where not hide'); $row = mysql_fetch_row($res); echo $row[0]; ?> Rich > -----Original Message----- > From: rentAweek support [mailto:support@rentaweek.org] > Sent: 27 February 2003 17:32 > To: php-general@lists.php.net > Subject: [PHP] Counting table fields having specific values > > > I have a table where the row named "hide" can have a value 0 or 1. > I want to obtain a count of all the rows where "hide" has value 0. > > The following works on mysqladmin: > > SELECT SUM( hide = 0 ) FROM names LIMIT 0, - 1 > > Giving > > SUM( hide = 0 ) > 7 > > The PHP script statements generated are: > > $sql = 'SELECT SUM( hide = 0 ) FROM names LIMIT 0, > -1'; > $result = mysql_query($sql); > > What assignment statement do I need to write now to obtain the SUM value > as shown by mysqladmin please? > > TIA > > Mike > > > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > >

« previous php.general (#137440) next »