RE: [PHP] Show total records based on criteria

From: Date: Wed, 12 Nov 2003 14:16:02 +0000
Subject: RE: [PHP] Show total records based on criteria
Groups: php.general 
Request: Send a blank email to php-general+get-169271@lists.php.net to get a copy of this message
[snip] If you want blue eyes only you would handle that in the query; SELECT COUNT(eyeColor) FROM theTable WHERE sex = 'male' AND eyeColor = 'blue' And if your are returning one row ... $result = mysql_fetch_object($db); // no while loop echo "We have " . $result->colorCount . "guys with " . $result->eyeColor . "eyes!<br>\n"; [/snip] Dang early morning typos -- SELECT COUNT(eyeColor) AS colorCount FROM theTable WHERE sex = 'male' AND eyeColor = 'blue'

« previous php.general (#169271) next »