How can the Resource id #10, Resource id #11 issue be resolved when fetching and displaying data from multiple SQL queries in PHP?
The issue of "Resource id #10, Resource id #11" occurs when trying to fetch and display data from multiple SQL queries without properly handling the result resource. To resolve this issue, you need to fetch the data from each query and store it in separate variables before displaying it.
// Perform the first SQL query
$query1 = "SELECT * FROM table1";
$result1 = mysqli_query($connection, $query1);
// Fetch data from the first query
while($row = mysqli_fetch_assoc($result1)) {
// Display or process the data from the first query
}
// Perform the second SQL query
$query2 = "SELECT * FROM table2";
$result2 = mysqli_query($connection, $query2);
// Fetch data from the second query
while($row = mysqli_fetch_assoc($result2)) {
// Display or process the data from the second query
}