TheMayhem
06-19-2005, 09:36 PM
$item_info = mysql_query("SELECT * FROM `sales` where buyerid=0 AND datecompleted=0 AND type=1 AND ($time-datestarted)/86400 <= 5 ORDER BY $sort $order LIMIT $membersdisplay,$membersnum");
while ($item = mysql_fetch_array($item_info)) {
$move = mysql_fetch_array(mysql_query("SELECT * FROM `items` where id=$item[moveid]"));
echo "
<tr><td valign='bottom'>$item[date]</td><td valign='bottom'><input type='radio' name='move' value='$item[id]'></input>$type $move[name]</td>
<td valign='bottom'>$move[damage]</td><td valign='bottom'><a href='member.php?id=$seller[id]'>$seller[username]</a></td><td valign='bottom'>" . number_format($item[price]) . "</td></tr>";
}
From what I have been told, a left join is what I need to do but I'm really confused beyond belief on how to do it. As you can see above I have a normal looking while loop. What I want to do is order everything by $move[name]. The problem is right now I have to use a fetch array inside the loop to do so. How can I take that first query and sort everything by something inside the query such as $move[name]?
while ($item = mysql_fetch_array($item_info)) {
$move = mysql_fetch_array(mysql_query("SELECT * FROM `items` where id=$item[moveid]"));
echo "
<tr><td valign='bottom'>$item[date]</td><td valign='bottom'><input type='radio' name='move' value='$item[id]'></input>$type $move[name]</td>
<td valign='bottom'>$move[damage]</td><td valign='bottom'><a href='member.php?id=$seller[id]'>$seller[username]</a></td><td valign='bottom'>" . number_format($item[price]) . "</td></tr>";
}
From what I have been told, a left join is what I need to do but I'm really confused beyond belief on how to do it. As you can see above I have a normal looking while loop. What I want to do is order everything by $move[name]. The problem is right now I have to use a fetch array inside the loop to do so. How can I take that first query and sort everything by something inside the query such as $move[name]?