• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Creating a form dropdown from db

#1
[eluser]Bionicjoe[/eluser]
I've went through several articles on creating forms and dropdowns, but I'm not getting anywhere. I just want to get a list from my database and use the data for the select items.

Here's what I've got.

Controller
Code:
function sitedropdown()
    {
        $this->load->model('outage_model');
        $this->outage_model->sitedropdown();
    }
}

Model
Code:
function sitedropdown()
    {
        $q = $this->db->get('location.sitename');
            return $q->result_array();
    }

View
Code:
<?php
            //Call Submit function from controller.
            echo form_open('outage/submit_addticket');
?>
                <table>
                    <tr><td>Number</td><td>&lt;input type="text" name="ticketnumber"&gt;&lt;/td><tr>
                    <tr><td>Summary</td><td>&lt;input type="text" name="summary"&gt;&lt;/td><tr>
                    <tr><td>Location</td><td>&lt;?php echo form_dropdown('sitedropdown', [b]$somedata[/b]); ?&gt;</td><tr>
                    <tr><td>Start</td><td>&lt;input type="text" name="starttime"&gt;&lt;/td><tr>
                    <tr><td>End</td><td>&lt;input type="text" name="endtime"&gt;&lt;/td><tr>
                    <tr><td></td><td>&lt;input type="submit" value="Submit"&gt;&lt;/td><tr>
                </table>
            &lt;/form&gt;

The $somedata variable produces an error regardless of the variable name. I've tried several things, but I just can't get the data to the view.

If I've totally missed the boat on creating forms tell me. I'm still very new to CI, and have limited coding experience.


Messages In This Thread
Creating a form dropdown from db - by El Forum - 02-16-2010, 11:48 AM
Creating a form dropdown from db - by El Forum - 02-16-2010, 12:07 PM
Creating a form dropdown from db - by El Forum - 02-16-2010, 12:07 PM
Creating a form dropdown from db - by El Forum - 02-16-2010, 03:00 PM
Creating a form dropdown from db - by El Forum - 02-16-2010, 03:13 PM
Creating a form dropdown from db - by El Forum - 02-16-2010, 03:40 PM
Creating a form dropdown from db - by El Forum - 02-16-2010, 05:51 PM
Creating a form dropdown from db - by El Forum - 02-17-2010, 08:19 AM
Creating a form dropdown from db - by El Forum - 02-17-2010, 10:23 AM
Creating a form dropdown from db - by El Forum - 02-17-2010, 10:25 AM
Creating a form dropdown from db - by El Forum - 02-17-2010, 10:28 AM
Creating a form dropdown from db - by El Forum - 02-17-2010, 10:33 AM
Creating a form dropdown from db - by El Forum - 02-17-2010, 10:35 AM
Creating a form dropdown from db - by El Forum - 02-17-2010, 10:38 AM
Creating a form dropdown from db - by El Forum - 02-17-2010, 12:06 PM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.