I have table like this. The table result order by date.
I'm using codeigniter framework.
I want to print it out above result like below image.
Today, Yesterday can be display using helper function.
Model
function getData(){
$this->db->order_by('date','desc');
return $this->db->get('table')->result();
}
Controller
function index(){
$this->load->model('data_model');
$this->data['result'] = $this->data_model->getData();
$this->load->view('dat_view', $this->data);
}
View
<div>
<?php
if($result){
$date ='';
foreach($result as $row){
if(!$date){
$date = $row->date;
}else{
if($date != $row->date){
$date = $row->date;
}
}
echo 'Date : ' . $date;
echo '<li>'.$row->title.'</li>';
}
}
?>
</div>
above code display like below
Date : 2017-11-28 1. Some title A
Date : 2017-11-28 1. Some title B
Date : 2017-11-28 1. Some title C
Please help me to group this by any function or array or other.