"Ron Gallant" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> I am querying a list with a date field.  I want to order the list by the
> date field and only show each days date once with the other fields
showing.
>
> (row 1) 2001-08-19 - some text here.
> (row 2)                        more text under same date.  My date does
not
> show.
> (row 3) 2001-08-20 - Lots of text today.
> (row 4)                        Even more text here today.   My date does
not
> show.
> (row 5)                        Yes more text, date not showing.

This seems to be a recurrent question in various guises;

The idea is simple: sort by date (so all equal dates are together),
then keep a temporary variable set to the last-seen date.  When the
date changes, output a new date value.

========== example.php ============
<?php
    mysql_connect("host", "user", "pwd")
        or die("Error connecting: ".mysql_error());

    // return the 20 most recent items
    $query =
         "SELECT mydate,mytext "
        ."FROM table "
        ."ORDER BY mydate DESC "
        ."LIMIT 20";
    $result = mysql_db_query("dbase", $query)
        or die("Error querying: ".mysql_error());

    // show results in a table
    $lastdate = "";
    echo "\n<table>";

    while ($row = mysql_fetch_array($result)) {
        extract($row);

        if ($lastdate == $mydate)
            $t = "";
        else
            $t = $lastdate = $mydate;

        echo "\n\t<tr><td>$t</td><td>$mytext</td></tr>";
    }

    echo "\n<\table>";
?>
===============================



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to