Jump to content

COUNT similar records


RON_ron

Recommended Posts

my mysql has got a field called statez where it stores the STATE. How do I amend the code below by adding $SomeVar = $_POST['Hamburg']; to count the number of records of a particular state? ($SomeVar will represent the state)

 

$query = "SELECT statez, COUNT(statez)FROM distributors GROUP BY statez"; 	 
$results = mysql_query($query);
$returnS="";
while($line = mysql_fetch_array($results))
{
$returnS.= $line['COUNT(statez)'].",,".$line['statez'].",,,";
}
echo $returnS;

Link to comment
https://forums.phpfreaks.com/topic/212847-count-similar-records/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.