The query looks like this:
Code: Select all
$query = "SELECT location, COUNT(*), category FROM table1
WHERE category='football' GROUP BY location";
Code: Select all
$result = mysql_query($query);
while($row = mysql_fetch_array($result)){
echo $row['COUNT(*)'] ." ". $row['location'];
echo "<br />";
}?>3 California
6 Colorado
1 Florida
etc...
What I am trying to do is extract out the results (the COUNT value) based on location from the array into variables to use in other places. I know the code below is wrong but I hope it at least shows the intent.
$cal=$row['COUNT(*)'] while ($row['location'] ='California');
$col=$row['COUNT(*)'] while ($row['location'] ='Colorado');
$flo=$row['COUNT(*)'] while ($row['location'] ='Florida');
Then can display the variables in other places as needed.
echo $cal;
results in: "3"
I hope this makes sense as I am quite new to this stuff. So far nothing I have tried seems to work, Any suggestions on how to do this would be most helpful. Maybe using something besides the "fetch_array" would work better?
thanks a bunch,
ZH