Welcome Guest, Not a member yet? Register   Sign In
Can i pass two database table in the model to the controller to the view?
#1

[eluser]jeanel16[/eluser]
I have two tables the names are menudb and msgdb, I want to select all from menudb, and also select all from msgdb then display the two table on the inboxmsgview.php I dont know how to pass two variables in the view and i know this code can not be correct no matter what i do

$this->load->view('inboxmsgview', $data, $data1);

is it possible to pass two tables?
#2

[eluser]Abel A.[/eluser]
Maybe with objects? I don't know if the view supports objects, but worth a try.
#3

[eluser]dnc[/eluser]
It sounds like you will be returning arrays from both tables, right?


After both arrays are populated I would do this like:

Code:
$final_data = array_merge($data, $data1);
$this->load->view('inboxmsgview', $final_data);

#4

[eluser]kanjimaster[/eluser]
Remember that $data is just an associative array whose indexes will end up as variables in the view so you can simply do this

Code:
...
$data[‘menu’] = $this-menu_model->get_menu();
$data[‘inbox’] = $this->inboxmsg_model->get_inbox();
$this->load->view(‘inboxmsgview’, $data);

and you'll have two variables $menu and $inbox waiting for you in the view. It's quite normal to pass lots of variables this way.
#5

[eluser]jeanel16[/eluser]
thanks for the replies, this topic was solved at "Help is this a bug" forum folder Smile




Theme © iAndrew 2016 - Forum software by © MyBB