• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Create multidimensional array from two database tables for form_dropdown()

#4
[eluser]cpass78[/eluser]
Oh i see, well if the result you poseted was from the code I gave you, it worked perfectly, just formatted wrong. Youll need to build you own array in this case. *Thinks something like this will work.

Not done yet have to think about this a bit, give me a min

Code:
$this->db->select( 'c.id AS customer_id, c.name AS customer_name' );
$this->db->from( 'customers AS c' );
$this->db->join( 'projects AS p', 'p.customer_id = c.id', 'inner' );
$this->db->order_by( "c.name" );
$query_c = $this->db->get();
        
if ( $query_c->num_rows() > 0 )
{
   $row['customer'] = $query_c->result_array();
}

$this->db->select( '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->order_by( "c.name" );
$query_p = $this->db->get();
        
if ( $query_p->num_rows() > 0 )
{
   $row['project'] = $query_p->result_array();
}

return $row;


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

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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