PHP - Load Multiple Models Within Same Function of Controller Code Igniter - Stack Overflow PDF
PHP - Load Multiple Models Within Same Function of Controller Code Igniter - Stack Overflow PDF
Home
PUBLIC
Stack Overflow
Tags
Load multiple models within same function of controller code Ask Question
Users
igniter
Jobs
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.
3 Answers
$this->load->model('categoryModel');
$query = $this->categoryModel->getAllCategories();
if ($query)
{
$data['categoryRecords'] = $query;
}
$this->load->view('dashboardTemplate/template',$data);
1 ohh.. thanks a lot.. ok tell me how can i do this.. if i select one option from
first select box then it will give me options in 2nd select box according to
that.. i think it will be done by applying the onchange function of javascript.. i
dont know how to i do it here ,, and also if it will be done without refresing by
using ajax or jquery then it will be more good – user1972143 Jan 12 '13 at
10:54
$data['main_content'] = 'stockInView';
$query2 = $this->itemsModel->getAllItems();
if ($query2) {
$data['itemRecords'] = $query2;
}
$query = $this->categoryModel->getAllCategories();
if ($query) {
$data['categoryRecords'] = $query;
}
$this->load->view('dashboardTemplate/template', $data);
}
By using our site, you acknowledge that you have read and understand our Cookie Policy, Privacy Policy, and our Terms of Service.
https://stackoverflow.com/questions/14292452/load-multiple-models-within-same-function-of-controller-code-igniter 2/2