The query runs, and then a secondary query runs within that just to extract certain fields from another table.
Like so...
Code: Select all
$result = mysql_query ("SELECT * FROM stock ORDER BY $orderby ASC") or die(mysql_error());
while ($row = mysql_fetch_object($result))
{
$resultp = mysql_query ("SELECT * FROM products WHERE id = '$row->productid'");
while ($rowp = mysql_fetch_object($resultp))
{
}
}
I can see the only way to do that be via a 'JOIN', but then how do you order by the field from one table, and then by the field from another, ensuring it orders by the second field first.