I have 3 tables users(id,name,etc..), trips(id,user_id,from,to,destionation) , vactions(id,user_id,from,to,destionation). I use mysqli and i can not figure out how to do this I need to fetch this table like this
Array ( [0] => Array ( [id] => 1 [current_status] => 0 [username] => user1 [fullname] => Eric Norman [trips] = > Array ( [0] => Array ( [date_from] = 02/06/14 [date_to] = 05/06/14 [destination] = "Grece" ) [vacations] = > ) [1] => Array ( [id] => 2 [current_status] => 0 [username] => user2 [fullname] => Joe Grey [trips] = > Array ( [0] => Array ( [date_from] = 02/06/14 [date_to] = 05/06/14 [destination] = "Grece" ) [vacations] = > ) )
I've tried with left join but i doesn't work and my code now is only for users :
conn = new mysqli($host,$user,$password,$db); $result = mysqli_query($conn, "SELECT id, current_status, username, CONCAT(first_name,' ',last_name) as fullname FROM user"); while ($row = $result->fetch_assoc()) { $users[] = $row; }