Welcome Guest, Not a member yet? Register   Sign In
Creating a form dropdown from db
#6

[eluser]Bionicjoe[/eluser]
Ok. I think I'm closer with this, but no matter what I try I get an undefined variable error on my view page.

Controller
Code:
function addticket()
    {
        $this->template->set('title', 'Add ticket');
        $this->template->set('heading', 'Add Ticket');
        
        $this->load->model('outage_model');
        $data['row'] = $this->outage_model->sitedropdown();
            
        $this->template->load('template', 'addticket_view');
    }

Model
Code:
public function sitedropdown()
    {
    //    $q = $this->db->get('location');
    //        return $q->result_array();
            
        $query = $this->db->get('location')->result_array();
        $result = array();
        foreach($query as $q)
         $result[$q['locationid']] = $q['sitename'];

        return $result;
    }

View
Code:
echo form_open('outage/submit_addticket');
...
<tr><td>Location</td><td>&lt;?php echo form_dropdown($data); ?&gt;</td><tr>

I made a typo earlier and got several repeating index errors on the page, so I'm confident I'm getting an array to the page.


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



Theme © iAndrew 2016 - Forum software by © MyBB