Forum Moderators: coopster
[codes]
<?php
require("cooking.php");
$sql = "SELECT * FROM states ORDER BY name";
$resultID = mysql_query($sql, $linkID);
// Looping through the States
while ($row = mysql_fetch_assoc($resultID))
{
$ThisState = $row[abbrev];
$ThisStateName = $row[name];
// Getting record of current State
$sqlcount = "SELECT COUNT(*) FROM troupes WHERE State = '".$ThisState."'";
$CountTroupes = mysql_query($sqlcount, $linkID);
echo $ThisStateName . " (".$CountTroupes.")<br />";
}
mysql_close($linkID);
?>
[/codes]
// Getting record of current State
$sqlcount = "SELECT COUNT(colname) as totalrows FROM troupes WHERE State = '".$ThisState."'";
$ct = mysql_query($sqlcount, $linkID);
if ($row = mysql_fetch_array($ct)) $CountTroupes = $row['totalrows'];