Welcome Guest, Not a member yet? Register   Sign In
Create multidimensional array from two database tables for form_dropdown()
#1

[eluser]suntrop[/eluser]
I need a multidimensional array for a nested select field with form_dropdown().

I've got two tables, the first (customers) are for the optgroups. The seccond table holds all projects.
Currently my code looks like this …
Code:
$this->db->select('
   c.id AS customer_id,
   c.name AS customer_name,
   p.id AS project_id,
   p.title AS project_title
');

$this->db->from('customers AS c');
$this->db->join('projects AS p', 'p.customer_id = c.id', 'inner');
#$this->db->group_by("customer_id");
$this->db->order_by("c.name");
$query = $this->db->get();
        
if ($query->num_rows() > 0)
{
   return $query->result_array();
}
        
return FALSE;

But that code produces just a normal array. How can I turn it into a multi array to user with form_dropdown()?


Messages In This Thread
Create multidimensional array from two database tables for form_dropdown() - by El Forum - 07-24-2011, 09:59 AM



Theme © iAndrew 2016 - Forum software by © MyBB