Welcome Guest, Not a member yet? Register   Sign In
CI/jQuery
#8

[eluser]boony[/eluser]
Hi,

I'm not sure if I understand your problem, but if you want to populate a drop down box with values from your database this should work.

You should have a model, and in that model a function like this:
Code:
function drop_down_data()
    {
        $data = array();
        $this->db->select('your_field'); //Put your field name here
        $this->db->from('your_table'); //Put your table here
        $query = $this->db->get();
        foreach($query->result_array() as $row)
        {
            $data[$row['your_field']] = $row['your_field'];
        }
        return $data;
    }

Now in your controller you should have something like this:

Code:
function get_drop_down_data()
    {
        $data['somestuff'] = $this->your_model->drop_down_data();
        $this->load->view('your_view', $data);
    }

And in your view, make the form *NOTE* that I'm using the form helper here (have a look in the user guide) and you will need to do all the other stuff. But this will now give you a select with your values.

Code:
echo '<p>'. form_label('Some Name','your_field');
    echo form_dropdown('your_field', $somestuff) .'</p>';


Messages In This Thread
CI/jQuery - by El Forum - 05-22-2009, 01:45 AM
CI/jQuery - by El Forum - 05-22-2009, 02:09 AM
CI/jQuery - by El Forum - 05-22-2009, 02:13 AM
CI/jQuery - by El Forum - 05-22-2009, 02:31 AM
CI/jQuery - by El Forum - 05-22-2009, 02:58 AM
CI/jQuery - by El Forum - 05-22-2009, 03:04 AM
CI/jQuery - by El Forum - 05-22-2009, 03:51 AM
CI/jQuery - by El Forum - 05-22-2009, 05:27 AM



Theme © iAndrew 2016 - Forum software by © MyBB