Originally Posted by Old Pedant
Your HTML there is ILLEGAL. You have no </tr> to match each <tr>.
Anyway, I don't use PHP, but I don't see why you couldn't have at least tried my query. The transformation of your code to use it iis nearly trivial.
$sql = "
SELECT L.lowest, E.*
FROM expedia AS E,
( SELECT tag, MIN(price) AS lowest
GROUP BY tag ) AS L
WHERE E.tag = L.tag
ORDER BY E.tag, E.price"; // change ORDER BY if you wish
$result = mysql_query( $sql ) or die( mysql_error() );
$rownumber = 0;
while( $rows = mysql_fetch_array($result) )
$lowest = "$" . $rows["lowest"];
$leg1 = $rows["leg1"];
$leg2 = $rows["leg2"];
$tag = $rows["tag"];
$url = $rows["url"];
$price = $rows["price"];
$ttl = "Lowest Price is $lowest for $leg1 - $leg2 with Search Tag : $tag";
<tr title="<?echo $ttl;?>">
<td align="center"><?echo $rownumber ?></td>
<td align='center' border='1' frame="box" rules="all"><? echo $tag; ?></td>
<td align='center' border='1' frame="box" rules="all"><? echo $url; ?></td>
<td align='center' border='1' frame="box" rules="all"><? echo $price; ?></td>
i do have the <tr></tr> but not in that paste.. it's before the code when i specify the headers and the </tr> is after the <td>'s at the bottom (have about 15 more columns i'm outputting, so i accidently deleted that to make my code paste a bit smaller and easier to read... sorry about that.
That does make more sense now, seeing it in the code.. but i didnt want to say "i dont get it , can you just do it for me?"
so E.* is getting everything from the table, and L. is getting the minimum price for each tag... is that correct?
so your $sql query returns: All items in database (as E) + minimum price (as L) from the same query..
I am now following you.. and this is (obviously) way better and faster than my nested query.. which in time, will be very slow.. I'm already at 3500 records..
Again, thanks so much for your help.. i'll give this a go.. i really appreciate it..