I want to make a table with values from two different tables. I do that with the while loop.
The problem now is, that I only get the output from the $result query, but I want the output from the $personalien and the $result query.
Is there a good way to merge these two mysqli results or how can I combine them so that the output from both is on the same line?
Here is the code:
// $res_anlassID is the number 5
$conn = mysqli_connect("localhost", "root", "", "art");
if ($conn-> connect_error) {
die("Connection failed" . $conn-> connect_error);
}
$sql = "SELECT schuetze.vorname, schuetze.nachname, schuetze.jahrgang, schuetze.ort
FROM schuetze
WHERE schuetze.id in (
SELECT resultate.schuetzeID
FROM resultate
WHERE resultate.anlassID = '$res_anlassID')";
$personalien = $conn->query($sql);
$sql = "SELECT resultate.vmTotalReh, resultate.vmTotalGams, resultate.vmTotalKlapphas, resultate.vmTotalRollhas, resultate.vmTotal, resultate.vmTiefschussReh, resultate.vmTiefschussGams
FROM resultate
WHERE resultate.anlassID = '$res_anlassID'";
$result = $conn->query($sql);
while ($row = $result-> fetch_assoc()) {
echo "</td><td>" . $row['vorname'] . "</td><td>" . $row['nachname'] . "</td><td>" . $row['jahrgang'] . "</td><td>" . $row['ort'] . "</td><td>" . $row['vmTotalReh'] . "</td><td>" . $row['vmTotalGams'] . "</td><td>" . $row['vmTotalKlapphas'] . "</td><td>" . $row['vmTotalRollhas'] . "</td><td>" . $row['vmTotal'] . "</td><td>" . $row['vmTiefschussReh'] . "</td><td>" . $row['vmTiefschussGams'] . "</td></tr>";
}
echo "</table>";
$conn-> close();