I’m working on a restaurants website. I’ve set it up where a customer can come online and order items off their menu. I have then tried to create an administrator side where they can view these orders. Here is where the problem is. The display currently looks like this:
Order ID|Contact Info |Order|Specials/Instructions|Date/Time to Fill
41|Test User, [email protected], 9125555555|Fried Fish Submarine with fries|Caesar Salad|Aug 31,2007 11:45
Looks great, however, the customer ordered more than just a fish submarine. The tables are set up as follows:
Orders
ID
Cus_Name
Cus_Phone
Cus_Email
Order_Date
Specials
Order_Items
ID
Order_ID
Item_ID
Quantity
Items
ID
Item_Name
Item_Price
Here is the code I am using to display the items:
[code]$resource = myQuery(“select * from “.ORDERSTABLE.” where active=‘y’ and for_date <= NOW() order by for_date”);
$nowOrders = array();
while (($row = mysql_fetch_assoc($resource)) !== false) {
$nowOrders[] = $row;
}
$itemid = array();
foreach ($nowOrders as $o) {
$resource = myQuery(“select * from “.OLINKTABLE.” where order_id=”.$o[‘id’]."");
while (($row = mysql_fetch_assoc($resource)) !== false) {
$itemid[$o[‘id’]] = $row;
}
}
$items = array();
foreach ($itemid as $o) {
$resource = myQuery(“select * from “.ITEMSTABLE.” where id=”.$o[‘item_id’]."");
while (($row = mysql_fetch_assoc($resource)) !== false) {
$items[$o[‘order_id’]] = $row;
}
}
<td><?php echo $o['id']; ?></td>
<td><?php echo $o['name'].', '.$o['email'].', '.$o['phone']; ?></td>
<td><?php echo $items[$o['id']]['name']; ?></td>
<td><?php echo $o['instructions']; ?></td>
<td><?php echo $date = date("M d,Y g:i", strtotime($o['for_date']));; ?></td>
<td><input type="checkbox" name="inactive[]" value="<?php echo $o['id']; ?>"/></td>
<?php
}
?>[/code]
Can anybody see what I am doing wrong? I can figure out why it is only displaying one order (even though in the table on the database side it shows multiple items under the Order_ID). I feel like it is something small as I am very close. I hope somebody can help with this.