Welcome Guest, Not a member yet? Register   Sign In
hwo to retrieve data from two tables and display it in single view
#11

[eluser]InsiteFX[/eluser]
If he wants to use objects then all he has to do is return this from his model queries.
Code:
$query->result();

// in view foreach loop
<?php foreach ($menudb as $menu): ?>
    // process the menu items using html anchor or whatever.
    <?php echo $menu->id; ?>
    <?php echo $menu->name; ?>
    // etc;
<?php endforeach; ?>

#12

[eluser]jeanel16[/eluser]
oh yes it is displaying all the table data from those two tables... but when i tried to var_dump($obj); in the view inboxmsgview.php it doesn't work it said undefined variable is there other way to pass data? i think im wrong Sad
#13

[eluser]Abel A.[/eluser]
once you pass the object to your view you can use the object as per InsiteFX's answer, just change the name of the object.
#14

[eluser]jeanel16[/eluser]
[quote author="InsiteFX" date="1337927049"]If he wants to use objects then all he has to do is return this from his model queries.
Code:
$query->result();

// in view foreach loop
<?php foreach ($menudb as $menu): ?>
    // process the menu items using html anchor or whatever.
    <?php echo $menu->id; ?>
    <?php echo $menu->name; ?>
    // etc;
<?php endforeach; ?>

[/quote]

yap i did that in my model return $query->result();

in my view i also did what you typed here and just fixed the braces of the foreach but it said undefined variable menudb Sad( im loosing hope.....
#15

[eluser]InsiteFX[/eluser]
He he uses the way I showedhim $data['menudb'] is already an object! If he retruns a $query->result(); from his model.
Code:
$query->result();       // returns object
$query->result_array(); // returns a pure array
$query->row();          // returns a single row object
$query->row_array();    // returns a single row array.

CodeIgniter Users Guide - Generating Query Results
#16

[eluser]jeanel16[/eluser]
oh i got it hahaha thanks, and im sorry im a slow learner, but i learned thanks a lot guys Smile)))
#17

[eluser]InsiteFX[/eluser]
Your very Welcome!




Theme © iAndrew 2016 - Forum software by © MyBB