Another noob question on passing $data - 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: Another noob question on passing $data (/showthread.php?tid=17467) |
Another noob question on passing $data - El Forum - 04-05-2009 [eluser]nubianxp[/eluser] hey guys, sorry for starting a series of noob posts but I was hoping you could extend some help and patience... I'm using the world.sql sample and I have the following code inside my controller (just for testing): Code: function index() { in my view_main.php Code: <ol> it's fine right now but how about if I want to pass the $data as Code: <?=$Region?> I apologize, but I've been browsing a lot of resources but I still don't get some of it for the life of me but I'm getting the $data variable concept a bit now. LOL Thanks for any help. Another noob question on passing $data - El Forum - 04-06-2009 [eluser]umefarooq[/eluser] hi if you are getting a single record from database than you can do some thing like in you controller Code: $sql = "SELECT Region FROM country"; Another noob question on passing $data - El Forum - 04-06-2009 [eluser]TheFuzzy0ne[/eluser] I'd suggest that you export things like that to a model, and then the model can pass your data back in whatever format you need. Another noob question on passing $data - El Forum - 04-06-2009 [eluser]nubianxp[/eluser] @umefarooq: thanks, how about if I need to do that on several items? @TheFuzzyOne: thanks, I'll be moving it to the Model on the actual application, right now I just use the controller for testing. So, any tips on how to do it on several items? e.g. Code: <?=$Name?> Thanks folks! Another noob question on passing $data - El Forum - 04-06-2009 [eluser]TheFuzzy0ne[/eluser] Code: # Model method Assign values individually. Code: # Controller - Method 1 Use list(). Code: # Controller - Method 2 Merge the results. Code: # Controller - Method 3 None of this code has been tested, it serves simply to illustrate my suggestions. It's advisable to add some more logic to check for results where necessary, or to set the defaults. Another noob question on passing $data - El Forum - 04-06-2009 [eluser]nubianxp[/eluser] ah thanks, I'll try them out, guess I'll need to expand my PHP. |