i want to search the result by year. i get undefined variable:q . where is the problem?
this is my view
<?php echo form_open("announcement/year");?>
<?php echo form_label('Year','q');?>
<?php echo form_dropdown('q', $q, set_value('q'), 'id="q"'); ?>
<?php echo form_close();
this is my controller
if ($q == '') $q = $this->input->post('q');
$this->data['q'] = $q;
if ($q == '') redirect($this->announcement);
$this->data['data'] = $this->ann_model->get_year
this is my model
function get_list_search($q)
{$result1 = array();
$sql = "SELECT * FROM Announcement
WHERE Date LIKE '%$q%'
ORDER BY ID DESC";
........}
please help me. Thanks :)
I think you have to change this
$this->data['data'] = $this->ann_model->get_year
to
$this->data['data'] = $this->ann_model->get_list_search($q);
And in model return the query result.