I have a table with the following info:
id | user_id | points
--------------------------
1 | 12 | 48
2 | 15 | 36
3 | 18 | 2
This code counts rows with date range:
Controller:
$this->load->model("YourModelName");
$data ['query'] = $this->YourModelName->get_report();
Model:
public function get_report()
{
$query = $this->db->query("SELECT *
FROM reservation WHERE arvdate <= '2016-7-20' AND dptrdate >= '2016-10-25' ");
return $query;
}
where 'arvdate' and 'dptrdate' are two dates on database and 'reservation' is the table name.
View:
num_rows();
?>
This code is to return number of rows. To return table data, then use
$query->rows();
return $row->table_column_name;