Creating agenda view with PHP MySQL - Divide fetched MySQL rows by year and month -


good afternoon everyone.

i've got mysql table organized this:

| id | date       | some_information           | +----+------------+----------------------------+ |  1 | 2016-03-02 | note day...   | |  2 | 2016-03-22 | note day...   | |  3 | 2016-04-05 | note...            | 

i need display data in similiar way google calendar app's agenda view. should:

  1. divide fetched rows, ordered date, month;
  2. before displaying data corresponding each month (let's march), display <div> heading corresponding month.

can please tell me if possible, , how?

mysql:

select     table.id,     table.date,     table.some_information,     month(table.date) m,     year(table.date) y table order table.date desc 

php:

$lastym = ''; foreach($result $row) {     $ym = $row['y'] . '-' . $row['m'];     if($ym != $lastym) {         echo '<div class="month">' . $row['m'] . '</div>';         $lastym = $ym;     }     echo '<div class="info">' . $row['some_information'] . '</div>'; } 

Comments

Popular posts from this blog

java - Static nested class instance -

c# - Bluetooth LE CanUpdate Characteristic property -

JavaScript - Replace variable from string in all occurrences -