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

[eluser]cpass78[/eluser]
Might need two queries, try something like this, might not be functional, basically creating a new array( $rows ) containing arrays of the results:
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 )
{
   $rows[] = $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 )
{
   $rows[] = $query_p->result_array();
}

return $rows;


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



Theme © iAndrew 2016 - Forum software by © MyBB