mysql expert assistance appreciated...
Posted: Fri Jul 24, 2009 1:29 am
I have a simple problem that looks long but is simple I am sure for any experienced programmer on this forum...Any assistance greatly appreciated
I query the database once and fetch the results which are represented by $mosttraffic. Everything is fine and i get 3 unique results listed together. When I use $mosttraffic in the next query I only get one result but I want 3. Anyone got ideas?
I query the database once and fetch the results which are represented by $mosttraffic. Everything is fine and i get 3 unique results listed together. When I use $mosttraffic in the next query I only get one result but I want 3. Anyone got ideas?
Code: Select all
query="SELECT td, COUNT(id) AS total FROM box GROUP BY td ORDER BY total DESC LIMIT 50";
$result1=mysql_query($query) or die('Error, select query failed');
while($row = mysql_fetch_array($result1)){
$mosttraffic=$row['td'];
echo $mosttraffic;
$query="SELECT * FROM tc WHERE td='$mosttraffic'";
$result2=mysql_query($query) or die('Error, select query failed');
while($row = mysql_fetch_array($result2)){
echo $row['tt'];
echo "<br />";
}
}