"Andres Sulleiro" <[EMAIL PROTECTED]> wrote in message
002001c18193$eacb4450$[EMAIL PROTECTED]">news:002001c18193$eacb4450$[EMAIL PROTECTED]...
> I have a db table that has these columns:
>         id, date, time, title, body
> some of the rows can have the same "date" and want to output the data
> according to "date". Like so:
>     dateA
>         timeA1, titleA1
>         bodyA1
>         timeA2, titleA2
>         bodyA2
>     dateB
>         timeB1, titleB1
>         BodyB1

In your SQL request, sort by date.  When printing the output,
keep track of the previous date - only print the date if it
changes.  Something like

    $conn = mysql_pconnect($host, $usr, $pwd);
    $sql = "SELECT id,date,time,title,body FROM mytable ORDER BY date DESC";
    $res = mysql_query($sql);

    $date = "previous date";
    while($row = mysql_fetch_array($res)) {
        if ($date != $row["date"]) {
            $date = $row["date"];
            echo "<br>$date";

        echo "<p>".$row["time"]." ".$row["title"];
        echo "<br>".$row["body"];

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