[SOLVED] learning how to pass data to a view - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: [SOLVED] learning how to pass data to a view (/showthread.php?tid=11803) |
[SOLVED] learning how to pass data to a view - El Forum - 09-24-2008 [eluser]M4rc0[/eluser] Hi all! I believe code igniter user guide is not very clear of how to pass data to a view. I am doing exactly what it says, although in the user guide example it's passing static data do the view and not dynamic, i think it should work anyway: controller Code: function latest() model Code: function get_latest() view Code: <h2><?=$header;?></h2> You see i'm trying many ways to show the data to find out how but none of them work :down: Help! Something so simple it should be explained on user guide *frustraded* [SOLVED] learning how to pass data to a view - El Forum - 09-24-2008 [eluser]xwero[/eluser] The result method gets you an array with as values objects so if you do Code: <h2><?=$header;?></h2> [SOLVED] learning how to pass data to a view - El Forum - 09-24-2008 [eluser]M4rc0[/eluser] That was fast! Thanks xwero! Now i get it. Array with object values *takes note* [SOLVED] learning how to pass data to a view - El Forum - 09-24-2008 [eluser]meigwilym[/eluser] * Edited, much better answer already Mei [SOLVED] learning how to pass data to a view - El Forum - 09-24-2008 [eluser]M4rc0[/eluser] I have one more question! Say i want to pass instead of many rows, just one. That was the browse view, then i'm linking each item as follow: Code: <a href="index.php/movie/id_here">(...)</a> So i click on the item and goes to show, show get's the data from db and etc My problem is, again, passing the data to the view. Since i have only one row, i don't need foreach, so then how to do? I can still use foreach for only one item? Isn't there a way to use $query->name or something? Thanks! [SOLVED] learning how to pass data to a view - El Forum - 09-24-2008 [eluser]xwero[/eluser] instead of result you have to use row and then you have a single object [SOLVED] learning how to pass data to a view - El Forum - 09-24-2008 [eluser]M4rc0[/eluser] Perfect! thanks again :cheese: |