0
I developed the following function:
public function get_agendas()
{
$this->db->select("*, EXTRACT(MONTH FROM data) as mes_referencia, count(id) as total_registros");
$this->db->where("data >=", date("Y-m-d"));
$this->db->group_by("EXTRACT(MONTH FROM data)");
$this->db->order_by('id', 'ASC');
$consulta = $this->db->get('agenda')->result();
foreach($consulta as $valor){
$valor->lista_agenda = $this->db->get('agenda')->result();
}
return $consulta;
}
My question is the following: At the time to list all the records belonging to that month, as I would SQL?
I have 4 records in the database:
I need to display it this way:
Month 04 Record 1 Record 2
Month 05 Record 1
Month 06 Record 1
The first part, I already know that will search how many records and I can even display the month correctly, but in the second part of the code within foreach(), I do not know how to do. Thanks!
You want to display the amount of records per month or want to display the records grouped month by month?
– rodorgas