Howdee, I'm trying to send two MySQL queries, each for a different table, to connect the results afterwards into a single array for further processing. Here's my code:
function list_invoice($invoice_id){
global $conn;
$query_getinvoice = "SELECT * FROM invoices WHERE id = ".$invoice_id;
$query_getlines = "SELECT * FROM invoice_lines WHERE invoice_id = ".$invoice_id;
$result = $conn->query($query_getinvoice);
$result2 = $conn->query($query_getlines);
$invdata = $result->fetch_array(MYSQLI_ASSOC);
$invdata2 = $result2->fetch_array(MYSQLI_ASSOC);
$the_data = array_merge($invdata,$invdata2);
}
My problem with the code above is that in invoice_lines table there are actually three rows with the same invoice_id, but the print_f($the_data) or even print_f($result2) returns only one row. Why's that?