[eluser]JoostV[/eluser]
[EDIT] removed a superfluous or_where
Say you do you query in the index() method of your controller. Then you would get this.
Code:
function index() {
// Set up the dates to query
$dates = array("2008-11-22", "2008-12-06", "2008-11-30", "2008-11-29", "2008-11-23");
// Get results
$data = $this->_date_query($dates)
}
function _date_query($dates) {
// Query database
$this->db->select_sum('total','total');
foreach($dates as $date) {
// Set a where statement for each date
$this->db->or_where('date', $date);
}
$query = $this->db->get('sale',$sql7);
// Return results
if($query->num_rows() > 0){
return $query->result_array();
}
else {
return false;
}
}
You had best move the _date_query($dates) function to a model, bacause it handels db actions. (remove the underscore from the function name, in that case.)