Welcome Guest, Not a member yet? Register   Sign In
hwo to retrieve data from two tables and display it in single 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]InsiteFX[/eluser]
Code:
$data['menudb'] = query_from_menudb;
$data['msgdb']  = query_from_msgdb;

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

You will need to loop through the data in your view.
#3

[eluser]jeanel16[/eluser]
I have this code in my controller

Code:
$this->load->model('inboxmsgmodel');
$data['data'] = $this->inboxmsgmodel->inboxview();
$data['messages'] = $this->inboxmsgmodel->inboxview2();
$this->load->view('inboxmsgview', $data);

is this correct? and i dont know how to view my data on two tables in one view im sorry im new in codeigniter Sad
#4

[eluser]jeanel16[/eluser]
how will i loop? oh my sorry for many questions Sad
#5

[eluser]Abel A.[/eluser]
have you tried using objects? it's worth a shot.
#6

[eluser]jeanel16[/eluser]
no i dont know how Sad

my task is to create a table which contains

menudb
id menu_name
1 inbox
2 sent
3 settings
4 reports

it needs to be displayed in the view at the left side it will be a navigating link that if i click on the inbox the msgdb table will appear

msgdb table
id email name subject message date
1 [email protected] heidi Hello! hi! 05/25/2012

i dont know how i can make the two tables appear waaaaaaa xD
#7

[eluser]jeanel16[/eluser]
i REALLY appreciate ur replies Sad
#8

[eluser]Abel A.[/eluser]
don't know if this will work, but try it:

Code:
$this->load->model('inboxmsgmodel');
$obj->data1['data'] = $this->inboxmsgmodel->inboxview();
$obj->data2['messages'] = $this->inboxmsgmodel->inboxview2();
$this->load->view('inboxmsgview', $obj);
#9

[eluser]jeanel16[/eluser]
then when i am in my inboxmsgview.php how can i specify if what data am i going to display?

i tried var_dump($obj);
to test if the object has something inside but it said undefined variable: obj
#10

[eluser]Abel A.[/eluser]
[quote author="jeanel16" date="1337926652"]then when i am in my inboxmsgview.php how can i specify if what data am i going to display?

i tried var_dump($obj);
to test if the object has something inside but it said undefined variable: obj [/quote]

Something is wrong with your data because it should display something when you do a var_dump.

Did you tried:
Code:
$this->load->model('inboxmsgmodel');
$obj->data1['data'] = $this->inboxmsgmodel->inboxview();
$obj->data2['messages'] = $this->inboxmsgmodel->inboxview2();
var_dump($obj);
exit;

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




Theme © iAndrew 2016 - Forum software by © MyBB