my database table structure is like following:
wdt date teacherid
1 2011-01-11 1001
2 2011-01-11 1002
3 2011-01-12 1001
4 2011-01-12 1002
Now what I want to do is select the date field from the table where teacherid=”1001″ and then return the result as an array like this- array(“2011-01-11″,”2011-01-12”)
so that in my view file I can check if a particular data exists in the array result- like following :
if (in_array("2011-05-18", $date)) // here the $date would be the array result which -
// I am expecting to get from model via controller
{
echo "Found";
}
My controller looks like following:
function index(){
$this->load->model('mod_teacher_workingday');
$data['date']= $this->mod_teacher_workingday->get();
$data['main_content']='view_teacher_workingday';
$this->load->view('includes/template',$data);
}
Would you please kindly show me how my model should look like in order to get the result as an array in my view file and I can check if a particular data exists in that array? Just for your information I am using Codeigniter.
Thanks 🙂
Should be:
The returned array will be just empty in case of no results found for that ID.