Creating a dynamic drop down list |
I'm trying to create a page that you can create a new menu and edit a menu.
In that page I have a drop down list that lists all the menus that has been saved and a textbox where I can add or edit a menu. The problem I'm having is that I can't get the drop down list to display the menus that are already in the database. Here is my menus.php controller Code: function create() and this is my create.php view Code: <div class="row">
Dont know exactly what you do, but first of all you should not mix database stuff in the controller. You should have a model for all of your database operations.
In your example you try to get all items from the table "title" and there the field title. In the loop you set a variable to the title and on every iteration its been overwritten. You should save it in an array like PHP Code: $titles = array(); In your view you can then loop over the items PHP Code: <?php foreach($titles as $title): ?> I think you have to do some refactoring to make a clean code for your project ;o) So as homework have a look at the Code: $query->result_array()
|
Welcome Guest, Not a member yet? Register Sign In |