[eluser]CI_Newb[/eluser]
Didn't think this would be that hard but yet I just can't get this to work.
Creating a search feature to search 1 table but with many different form elements.
I have 2 controllers. 1 for the initial page, 1 to get results.
Code:
function search()
{
$this->load->model('search_model');
$data['tracking_options'] = $this->search_model->ns_tracking_menu();
$data['incident_menu'] = $this->search_model->ns_incident_type_menu();
$data['checkbox_menu'] = $this->search_model->checkbox_menu();
$this->load->view('ns/incident_search_view', $data);
}
function search_results()
{
$this->load->model('search_model');
$data['tracking_options'] = $this->search_model->ns_tracking_menu();
$data['incident_menu'] = $this->search_model->ns_incident_type_menu();
$data['checkbox_menu'] = $this->search_model->checkbox_menu();
$data['search_result'] = $this->search_model->ns_incident_search();
$this->load->view('ns/incident_search_view', $data);
}
Model
Code:
function ns_incident_search()
{
$start_date = $this->input->post('start_date');
$end_date = $this->input->post('end_date');
$nsAgent = $this->session->userdata('username');
$flagent_id = $this->input->post('flagent_id');
$manager_id = $this->input->post('manager_id');
$employee_city = $this->input->post('employee_city');
$stn = $this->input->post('stn');
$level1 = $this->input->post('level1');
$level2 = $this->input->post('level2');
$level3 = $this->input->post('level3');
$dslam = $this->input->post('dslam');
$notes = $this->input->post('notes');
$valid = $this->input->post('valid');
$resolution = $this->input->post('resolution');
$rescomments = $this->input->post('rescomments');
$tsmissed = $this->input->post('tsmissed');
$tracking = $this->input->post('tracking');
$oe_related = $this->input->post('oe_related');
$oe_stuckOrder = $this->input->post('oe_stuckOrder');
$np_failure = $this->input->post('np_failure');
$incident_type = $this->input->post('incident_type');
$query = $this->db->query("SELECT *
FROM data
WHERE tdate BETWEEN '$start_date' and '$end_date'
AND username = '$nsAgent'
AND stn LIKE '$stn%'
AND dslam LIKE '%$dslam%'
AND flagent_id LIKE '$flagent_id%'
AND resolution LIKE '$resolution%'
AND rescomments LIKE '%$rescomments%'
AND valid LIKE '$valid%'
AND level1 LIKE '$level1%'
AND level2 LIKE '$level2%'
AND level3 LIKE '$level3%'
AND notes LIKE '%$notes%'
AND oe_related LIKE '$oe_related%'
AND oe_stuckOrder LIKE '$oe_stuckOrder%'
AND np_failure LIKE '$np_failure%'
AND manager_id LIKE '$manager_id%'
AND incident_type LIKE '$incident_type%'
AND tsmissed LIKE '%$tsmissed%'
ORDER BY tdate");
if($query->num_rows() > 0) {
$data = $query->row();
return $data;
}
}
displaying on simple table echoing $search_result
Yet this doesn't work and I know its probably something really simple i'm not doing right.
Help?