i have two table in sql database 1st is booking and it has customers details and another is booking_line it has purchased products history by customers now i want both results in a array like following image i just want an array named Customer has all purchased details customers wise
array(
[0] => array(
[id] => 67
[name] => Neha
[mobile_no] => xxxxxxxxx
[gender] => Female
[Sale] => Array
(
[id] => 1
[booking_id] => 67
[barcode] => 1368
[product_name] => Custom Print Mattel Rakhi BE
[p_price] => 35
[price] => 100
)
[Sale] => Array
(
[id] => 2
[booking_id] => 67
[barcode] => 1368
[product_name] => Custom Print Mattel Rakhi BE
[p_price] => 35
[price] => 100
)
)
[1] => array(
[id] => 68
[name] => Nehaxx
[mobile_no] => xxxxxxxxx
[gender] => Female
)
Currently i got the output like this
array(
[0] => array(
[id] => 67
[name] => Neha
[mobile_no] => xxxxxxxxx
[gender] => Female
)
[1] => array(
[Sale] => Array
(
[id] => 1
[booking_id] => 67
[barcode] => 1368
[product_name] => Custom Print Mattel Rakhi BE
[p_price] => 35
[price] => 100
)
)
[2] => array(
[id] => 68
[name] => Nehaxx
[mobile_no] => xxxxxxxxx
[gender] => Female
)
[1] => array(
[Sale] => Array
(
[id] => 1
[booking_id] => 67
[barcode] => 1368
[product_name] => Custom Print Mattel Rakhi BE
[p_price] => 35
[price] => 100
)
)
)
and my code is
$sqlA = "SELECT * FROM booking";
$resultA = $conn->query($sqlA);
$dataA = array();
while($rowA = $resultA->fetch_assoc()) {
$sql = "SELECT * FROM booking_line WHERE booking_id=".$rowA["id"]."";
$result = $conn->query($sql);
$dataA[] = $rowA;
while($row = $result->fetch_assoc()) {
$dataA[] = array("Sale" => $row);
}
}
print_r($dataA);