mysql expert assistance appreciated...

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
scarface222
Forum Contributor
Posts: 354
Joined: Thu Mar 26, 2009 8:16 pm

mysql expert assistance appreciated...

Post 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 />";
}
}
Last edited by scarface222 on Fri Jul 24, 2009 10:41 pm, edited 2 times in total.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: mysql expert assistance appreciated...

Post 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"...
scarface222
Forum Contributor
Posts: 354
Joined: Thu Mar 26, 2009 8:16 pm

Re: mysql expert assistance appreciated...

Post 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
scarface222
Forum Contributor
Posts: 354
Joined: Thu Mar 26, 2009 8:16 pm

Re: mysql expert assistance appreciated...

Post by scarface222 »

nvm It was a database problem... thanks anyways guys
Post Reply