sql >> Base de Datos >  >> RDS >> Mysql

Ordenar y agrupar resultados por fecha

Esta es una 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>";
    }
?>