The following SQL query does work as I’ve tried it in phpMyAdmin and it returned results, however when I plug it into my PHP page no results are displayed I’ve shown below how I’m doing it - I’d really appreciate it if someone could let me know what am I doing wrong!
Cheers
$sql = "SELECT tours.location, MAX(tourbids.bid)
FROM tourauction
LEFT OUTER JOIN tours ON tours.tourid = tourauction.tourid
LEFT OUTER JOIN tourbids ON tourbids.tourid = tourauction.tourid
GROUP BY tours.location
ORDER BY tourauction.auctionid desc LIMIT 10";
$sqlallstuff = mysql_query($sql);
while($row_gen2 = mysql_fetch_array($sqlallstuff))
{
print($row_gen2['tours.location']);
print($row_gen2['tourbids.bid']);
}
Oh OK, that basically fixed it - thanks very much. For some reason the print($row_gen2[‘bid’]); didn’t work, however printing location and tourid (from the SQL below) did. If I remove the MAX() from around the tourbids.bid then I can print out the bid, however with the MAX it just doesn’t print anything.
Any idea?
SELECT tours.location, MAX(tourbids.bid), tourauction.tourid
FROM tourauction
LEFT OUTER JOIN tours ON tours.tourid = tourauction.tourid
LEFT OUTER JOIN tourbids ON tourbids.tourid = tourauction.tourid
GROUP BY tours.location
ORDER BY tourauction.auctionid desc LIMIT 10