[eluser]msank[/eluser]
Hi,
I am new here, and was needing to figure out how I can pass two values at the same time from two form input fields to a search feature... The values are hidden, and predetermined based on which page the user is on.
This is the form:
Code:
<?php
echo form_open('/products/search') . "\n";
echo form_hidden('search', '258') . "\n";//Value 1 to be used for searching
echo form_hidden('search', '900') . "\n";//Value 2 to be used for searching
echo form_submit('submit', 'Go') . "\n";
echo form_close() . "\n";
?>
This is the controller:
Code:
function search() {
$search = $this->input->post('search');
$this->load->model('web_inventory_model');
$inventory = $this->web_inventory_model->searchInventory($search);
if($inventory !== FALSE) {
$results = $inventory->result_array();
} else {
$results = 'There are no results';
}
$data = array(
'search' => $search,
'inventory' => $results,
'title' => 'Search Results for "' . $search . '"',
'locations' => $this->locations,
'readMore' => $this->readMore
);
$this->load->view('search_view', $data);
}
This is the model:
Code:
function searchInventory($search) {
$this->db->like('item_desc', $search);
$this->db->or_like('item_no',$search);
$this->db->or_like('manu_no',$search);
$query = $this->db->get('Web_Inventory');
if($query->num_rows > 0) {
return $query;
} else {
return FALSE;
}
}
At this point in time it is only using the last input value (900) to search. I would like it to use both input values at the same time, and display all of the results on the same page.
Any help is appreciated!