Having a little trouble getting my query to order how I would like it to here. Obviously my method is not working and i would like to order to the total_plays on the games table but do to the while calling from the tag table first it don’t get ordered accordingly. Any help would be great.
<div id="section" style="width:542px;clear:left;">
<div id="header">Top <?php echo ucfirst($value); ?> Games</div>
<?php
$i = 0;
$query = mysql_query("SELECT * FROM tags WHERE tag='".$value."' ORDER BY game_id DESC") or die(mysql_error());
while($tag = mysql_fetch_array($query)){
$q = mysql_query("SELECT * FROM games WHERE id='".$tag['game_id']."' ORDER BY total_plays DESC") or die(mysql_error());
$games = mysql_fetch_array($q);
if($i < 6){ ?>
<div id="icon" onmouseover="this.style.backgroundColor='#333'" onmouseout="this.style.backgroundColor='#222'" onclick="document.location.href='http://www.gamejunkie.ca/game/<?php echo $games['id']; ?>'" style="width:257px;">
<table border="0px" cellpadding="0px" cellspacing="0px" style="width:100%;">
<tr>
<th colspan="2"><?php echo $games['name']; ?></th>
</tr>
<tr>
<td style="width:75px;" rowspan="2"><img style="height:75px;border:1px solid black;" src="<?php echo $games['thumb_loc']; ?>" /></td>
<td style="width:100%;height:65px;font-size:9px;font-family:Verdana, Geneva, sans-serif;text-align:left;vertical-align:text-top;"><?php echo truncateString($games['description'], 150); ?> </td>
</tr>
<tr>
<td style="width:100%;font-size:9px;font-family:Verdana, Geneva, sans-serif;text-align:left;vertical-align:text-top;"> <?php echo number_format($games['total_plays']); ?> Plays</td>
</tr>
</table>
</div>
<?php $i++;
}
}?>
</div>