Mysql
 sql >> Database >  >> RDS >> Mysql

Ordina e raggruppa i risultati per data

Questa è un'idea:

<?php
    $sql = "SELECT * FROM posts ORDER by post_date DESC";
    $res = mysql_query($sql);

    $previous_date = "";
    while($post = mysql_fetch_assoc($result)){
        //here goes the date
        if($post['post_date'] != $previous_date){
            echo $post['post_date'];
            echo "<br>--------------------<br>";
            $previous_date = $post['post_date'];
        } 
        //here goes the post
        echo "Post:{$post['title']}<br>";
    }
?>