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

[eluser]mdcode[/eluser]
Hey jedd, thanks for getting back to me. Looking through the CI documentation, I followed your advice at attempting (apparently poorly since you say it's still wrong), to pass an array result to the controller to display in the view, like this:

Model:
Code:
function get_customers()
    {
        /* customer selection query */
        $this->db->select('*');
        $this->db->from('customers');
        $this->db->order_by("customerName", "ASC");
        $cust_query = $this->db->get();
        
            foreach ($cust_query->result_array() as $row)
            {
            $row['customerid'];
            $row['customerName'];
            }
            
        return $cust_query;
    }

I changed the basic query since I'm more familiar with MySQL query strings as well (I just wanted to learn the AR way and use it). The controller is I think still the same but here it is again as it stands:

Controller:
Code:
$data['customers'] = $this->projects_model->get_customers();

And I know the <pre> part of HTML but have never used it; still, I have put it in the view along with print_r and this is what is shown in the view:

View:
Code:
CI_DB_mysql_result Object
(
    [conn_id] => Resource id #33
    [result_id] => Resource id #45
    [result_array] => Array
        (
            [0] => Array
                (
                    [customerid] => 1
                    [customerName] => Company 1
                )

            [1] => Array
                (
                    [customerid] => 2
                    [customerName] => Company 2
                )

        )

    [result_object] => Array
        (
        )

    [current_row] => 0
    [num_rows] => 2
    [row_data] =>
)


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