Welcome Guest, Not a member yet? Register   Sign In
Dont repeat myself...? -- Populating dropdown with DB data

Well it works now..
function in controller:
function listPrio()
        $qpriority = $this->Smtm->getPriority();
        $ddmenu = array();
        foreach($qpriority->result_array() as $row)
            $ddmenu[$row['PartPriority]] = $row['PartPriority];
        $priority['options'] = $ddmenu;
        $this->load->view('test', $priority);

function in model:
function getPriority()
        $this->db->select('PartPriority, PartPriorityID');
        $priority = $this->db->get();
        return $priority;

        <?php echo form_('PartPriority, $options); ?>

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.

Messages In This Thread
Dont repeat myself...? -- Populating dropdown with DB data - by El Forum - 01-08-2008, 04:03 PM

Theme © iAndrew 2016 - Forum software by © MyBB