Welcome Guest, Not a member yet? Register   Sign In
Form field data pulled from database
#10

[eluser]mdcode[/eluser]
I think I almost have it... But - you saw that one coming right? - while I get a populated select box, all it's populated with it this:
Code:
Resource id #33
Resource id #45
result_array (formatted as an option group)
result_object (formatted as an option group)
0
2
blank-line

The model is shown as this:
Code:
function get_customers()
    {
        /* customer selection query */
        $this->db->select('*');
        $this->db->from('customers');
        $this->db->order_by('customerName');
        $cust_query = $this->db->get();
        
        return $cust_query;
        
            foreach ($cust_query->result() as $row)
            {
            echo $row->customerid;
            echo $row->customerName;
            }
    }
The controller is this:
Code:
function add()
    {
        $data['siteTitle'] = $this->config->item('siteTitle');
        $data['customers'] = $this->projects_model->get_customers();
        $this->template->write_view('content', 'default/admin/projects_add', $data);
        $this->template->render();
    }
And the view:
Code:
echo form_dropdown('customer', $customers, '');

Now if I put the foreach loop in the controller as suggested, I can echo out the customer id's and names, but the select box still populates with the items above.

As some asides, I have been trying to follow the CI formatting procedures, and the only place where I have been using camelCase is in my field names, which I understood was ok and usual, unless you have seen something else that I have been doing wrong...??

Still, have a good night and hopefuly someone else can offer more insight as to what is going on.


Messages In This Thread
Form field data pulled from database - by El Forum - 03-16-2009, 06:54 PM
Form field data pulled from database - by El Forum - 03-16-2009, 07:09 PM
Form field data pulled from database - by El Forum - 03-16-2009, 07:28 PM
Form field data pulled from database - by El Forum - 03-16-2009, 07:49 PM
Form field data pulled from database - by El Forum - 03-16-2009, 07:55 PM
Form field data pulled from database - by El Forum - 03-16-2009, 07:56 PM
Form field data pulled from database - by El Forum - 03-16-2009, 08:04 PM
Form field data pulled from database - by El Forum - 03-16-2009, 08:12 PM
Form field data pulled from database - by El Forum - 03-16-2009, 08:24 PM
Form field data pulled from database - by El Forum - 03-16-2009, 09:23 PM
Form field data pulled from database - by El Forum - 03-16-2009, 09:58 PM
Form field data pulled from database - by El Forum - 03-16-2009, 11:17 PM
Form field data pulled from database - by El Forum - 03-17-2009, 03:14 AM
Form field data pulled from database - by El Forum - 03-17-2009, 03:30 PM
Form field data pulled from database - by El Forum - 03-18-2009, 06:17 AM
Form field data pulled from database - by El Forum - 03-18-2009, 07:58 AM
Form field data pulled from database - by El Forum - 03-18-2009, 04:17 PM
Form field data pulled from database - by El Forum - 03-18-2009, 05:38 PM
Form field data pulled from database - by El Forum - 03-18-2009, 06:51 PM
Form field data pulled from database - by El Forum - 03-18-2009, 07:10 PM
Form field data pulled from database - by El Forum - 03-18-2009, 07:22 PM
Form field data pulled from database - by El Forum - 03-18-2009, 07:44 PM
Form field data pulled from database - by El Forum - 03-18-2009, 09:00 PM
Form field data pulled from database - by El Forum - 03-18-2009, 09:54 PM



Theme © iAndrew 2016 - Forum software by © MyBB