• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
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

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.