Dont repeat myself...? -- Populating dropdown with DB 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: Dont repeat myself...? -- Populating dropdown with DB data (/showthread.php?tid=5144) |
Dont repeat myself...? -- Populating dropdown with DB data - El Forum - 01-08-2008 [eluser]rvent[/eluser] Hello, I am back at my CI intranet project and i have found this post: http://ellislab.com/forums/viewthread/64256/ I ended up with the following function in the controller: Code: function listPrio() Function in the Model: Code: function createBoard() And view: Code: <html> But i get a blank page.. Any ideas..? Thanks Dont repeat myself...? -- Populating dropdown with DB data - El Forum - 01-08-2008 [eluser]rvent[/eluser] Having the controller the way i do would it allow me to also know the ID of the item selected..? Thanks Dont repeat myself...? -- Populating dropdown with DB data - El Forum - 01-08-2008 [eluser]sandwormusmc[/eluser] Have you tried either returning $priority->result_array() or passing $options->result_array() into the form_dropdown function? If that doesn't work, check to see what data your view is receiving by doing a print_r($data) or print_r($options) ... Dont repeat myself...? -- Populating dropdown with DB data - El Forum - 01-08-2008 [eluser]rvent[/eluser] Well it works now.. function in controller: Code: function listPrio() function in model: Code: function getPriority() view: Code: <html> Now, there are a few of the same kind i will need to do, like partLocation, PartNumber, PartState, PartStatus, etc. Those will only be dropdown since they are static data, but each value represents a different phase during the repair. How can i avoid to repeat myself on the code...? Since the only thing that will be changing is the table that is being query..? Basically, i will have a form for a "board" creation, that form will have several fields; the fields mentioned above reside on different tables and are foreign keys on the main table. So i will need to ID and value field of each of those query... Will i have to repeat myself..? i dont mind repeating myself, but i think it defeats the purpose of the MVC..? Thanks for any inputs. |