Page 1 of 1

mysql expert assistance appreciated...

Posted: Fri Jul 24, 2009 1:29 am
by scarface222
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?

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 />";
}
}

Re: mysql expert assistance appreciated...

Posted: Fri Jul 24, 2009 1:37 am
by requinix
You get results at all? I see your first query has "td" and "total" but on line 5 you try to get "topic_id"...

Re: mysql expert assistance appreciated...

Posted: Fri Jul 24, 2009 9:56 am
by scarface222
lol thanks yeah that was just a mistake its all supposed to be td... sorry but I have it proper in my actual code so I still have the same problem

Re: mysql expert assistance appreciated...

Posted: Fri Jul 24, 2009 8:40 pm
by scarface222
nvm It was a database problem... thanks anyways guys