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

[eluser]jedd[/eluser]
Quote:
Code:
function get_customers()
    {
        /* customer selection query */
        $this->db->select('customerid', 'customerName');
        $this->db->from('customers');
        $this->db->order_by('customerName');
        $this->db->get();
    }

This is in your model, right? If it's not, then it should be.

In any case, have a re-read of the CI Manual pages on [url="http://ellislab.com/codeigniter/user-guide/database/active_record.html"]Active Record[/url] and [url="http://ellislab.com/codeigniter/user-guide/database/results.html"] Processing database results [/url]

Quote:Now I'm not quite sure what to put in the controller to make it pass this into the view, and what attributes to put on the select box to make it display the values -- I'm getting the same errors as before still.

Your last line above - you need to actually use the output of the db->get() function. So instead have something like:
Code:
$foo = $this->db->get();
return $foo;

In your controller, you can process that data like this:

Code:
$customers = $this->projects_model->get_customers();

foreach ($customers->result() as $row)
{
    echo $row->customerid;
    echo $row->customerName;
    echo $row->body;
}

Code is very much untested, of course - as I tend to use this->-db->query() stuff instead of AR.

Btw, I concur with CI's style guide - avoid CamelCase (ItBlowsBigTime) - use underscores between words instead. Also you almost definitely do not want a customerid column in a table called customer. Just call it id instead. Ditto for 'customer.customerName' (etc).


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