mysqli_multi_query.php
<?php
$mysqli = new mysqli("127.0.0.1", "root","", "mydatabase");
$userid = $_SESSION['userid'];
$query = "SELECT lastname, firstname FROM user WHERE userID='$userid';";
$query .= "SELECT product_count, CONCAT('$',total_cost) FROM sales WHERE userID='$userid'";
if($mysqli->multi_query($query)) {
do {
$result = $mysqli->store_result();
while ($row = $result->fetch_row())
echo "$row[0], $row[1] <br />";
if ($mysqli->more_results())
echo "<br />";
} while ($mysqli->next_result());
}
?>
Related examples in the same category