Ell20 Posted July 24, 2008 Share Posted July 24, 2008 Hi, Im having a bit of trouble with the following query: $query = "SELECT colour, COUNT(colour),player_id,type, crews.id AS cid FROM dom_london INNER JOIN crews ON dom_london.colour = crews.crewcolour WHERE colour != 'ffffff' GROUP BY colour ORDER BY COUNT(colour) DESC LIMIT 3"; $result = mysql_query($query); $a = 1; while ($row = mysql_fetch_assoc($result)) { $winner.$a = $row['cid']; $a++; } echo $winner1.'<br>'; echo $winner2.'<br>'; echo $winner3.'<br>'; I am not getting any errors, its making the space for the echoing of the statements but its not actually displaying anything. The main part im unsure about is "crews.id AS cid", is this the correct way to put the column name if there is the same column name in the two tables which are being joined? Any help is appreciated Elliot Link to comment https://forums.phpfreaks.com/topic/116391-quick-question/ Share on other sites More sharing options...
unkwntech Posted July 24, 2008 Share Posted July 24, 2008 $winner.$a = $row['cid']; What are you trying to achieve with this line? Link to comment https://forums.phpfreaks.com/topic/116391-quick-question/#findComment-598494 Share on other sites More sharing options...
Ell20 Posted July 24, 2008 Author Share Posted July 24, 2008 Trying to retreive the ID from the crews table, however bother the crews and dom_london table have the field ID so I therefore used the crews.id AS cid? Not sure if this is correct? Cheers Link to comment https://forums.phpfreaks.com/topic/116391-quick-question/#findComment-598495 Share on other sites More sharing options...
samshel Posted July 24, 2008 Share Posted July 24, 2008 try ${"winner".$a} = $row['cid']; Link to comment https://forums.phpfreaks.com/topic/116391-quick-question/#findComment-598497 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.