I want show the rows of mysql table like this:
Today
Row1
Row2
....
Last day
Row1
Row2
...
Before last day
Row1
Row2
...
I have date column on my table: (id, message, date).
What is the method to show the result like the example i given ?
Here my approch in order to get the needed result:
$sql = $mysql->query("SELECT * FROM messages");
$array = array();
while($rows = mysql_fetch_array($sql)) {
//Get proper date for array
$key = date('Y-m-d', strtotime($rows["date"]));
$arr[$key] = $rows["message"];
}
var_dump($array);
I want know if there a simple way to do it without array, or any other method.
My problem is not based on how to get Today, Yesterday ... But on how to show the structure in the example that i given, and write for each date (Today, Yesterday ...) with a specific rows into the while loop
.