I am trying to make an order history page for my project. The data is stored in the database table called order_today which holds the ids of the food ordered. But I need to display the name of the food which is stored in another table called menu and combo. I am only getting the result for one entry in the order_today table. the loop is not running. can anybody help? PS: I am a newbie in php.
<?php require 'config.php' ?>
<div class="orderlist">
<div class="yourlist">
Your Order History:
<br>
<?php
session_start();
$sql = "select * from order_today where `user_id`='" . $_SESSION['uid'] ."';";
$result = mysqli_query($conn, $sql);
while ($row = $result->fetch_assoc()) {
$date = explode(' ', $row['time']);
$combo = unserialize($row['combo_id']);
$food = unserialize($row['food_id']);
?>
<div class="past-order">
<div class="Order-hist">
<h5><b>Order ID:<?php echo $row['Order_id']; ?></b></h5>
<div class="time-date">
<h6> Date:<?php echo $date[0]; ?><br>Time:<?php echo $date[1]; ?></h6>
</div>
<div class="odetails">
<?php
if (!empty($food['food'])) {
foreach ($food['food'] as $item => $itemQuantity) {
$sql1 = "select * from menu where `food_id`='" . $item . "';";
$result = mysqli_query($conn, $sql1);
while ($row1 = $result->fetch_assoc()) {
echo $row1['name'] . ' x' . $itemQuantity . '<br>';
}
}
}
if (!empty($combo['combo'])) {
foreach ($combo['combo'] as $item => $itemQuantity) {
$sql2 = "select * from combo where `combo_id`='" . $item . "';";
$result = mysqli_query($conn, $sql2);
while ($row2 = $result->fetch_assoc()) {
echo $row2['name'] . '(Combo) x' . $itemQuantity . '<br>';
}
}
}
?>
</div>
<div class="cost">
<h5>Cost: </h5>
</div>
</div>
</div>
<?php } ;?>
</div>
</div>