I have a page where I want to display dynamic two select boxes.One select box get data from one model and then other select box get from other.Then after getting the data it will save the query or result of both of them and then view into one view page .
I want to save the data in array of two queries and this is my controller:
function index(){
$data['main_content'] = 'stockInView';
$this->load->model('itemsModel');
$query2 = $this->itemsModel->getAllItems();
if ($query2)
{
$data['records'] = $query2;
}
$this->load->model('categoryModel');
$query = $this->categoryModel->getAllCategories();
if ($query)
{
$data['records'] = $query;
}
$this->load->view('dashboardTemplate/template',$data);
}
And then I display them in a foreach loop . But it is only able to display the 2nd query results or in this case display only categories in one select box and not the items in other select box.I am doing this for the first time so I don't know how to do it.