View Single Post
Old 11-27-2012, 10:26 PM   PM User | #26
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,556
Thanks: 62
Thanked 4,056 Times in 4,025 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
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.
Code:
<?php

$sql = "
    SELECT L.lowest, E.*
    FROM expedia AS E,
         ( SELECT tag, MIN(price) AS lowest
           FROM expedia
           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) ) 
{
    ++$rownumber;

    $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>
</tr>
<?php
}
mysql_free_result($result);
mysql_close();
?>
</table>
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
Old Pedant is offline   Reply With Quote
Users who have thanked Old Pedant for this post:
stevenryals (11-28-2012)