Table is unorganized and confusing
Posted: Tue Feb 03, 2015 8:26 am
Hi. I'm new here.
I need help with the tables. They are not organized/neat. (http://i.imgur.com/1LLpQ2G.png)
The tables have to look neat, understandable and not confusing. Someone help me. Below is the code.
I need help with the tables. They are not organized/neat. (http://i.imgur.com/1LLpQ2G.png)
The tables have to look neat, understandable and not confusing. Someone help me. Below is the code.
Code: Select all
<table>
<?php
$result = $mysqli->query("SELECT * FROM `order`");
while($obj = mysqli_fetch_assoc($result)) {
$orderDate = $obj['OrderDate'];
$orderId = $obj['OrderID'];
$totalAmount = $obj['OrderTotal'];
$paymentStatus = $obj['PaymentStatus'];
$customerId = $obj['CustomerID'];
$res = $mysqli->query("SELECT CustomerName, CustomerContactNo, CustomerEmail FROM customer WHERE CustomerID=$customerId");
if($row = mysqli_fetch_assoc($res)) {
$customerName = $row['CustomerName'];
$customerContactNo = $row['CustomerContactNo'];
$email = $row['CustomerEmail'];
}
?>
<tr>
<th>Customer Name</th>
<th>Customer Contact</th>
<th>Customer Email</th>
<th>Order ID</th>
<th>Order Date</th>
<th>Total Amount</th>
</tr>
<tr>
<td><?php echo $customerName;?></td>
<td><?php echo $customerContactNo;?></td>
<td><?php echo $email;?></td>
<td><?php echo $orderId;?></td>
<td><?php echo $orderDate;?></td>
<td>$<?php echo $totalAmount;?></td>
</tr>
<?php
$result1 = $mysqli->query("SELECT * FROM ordermenu WHERE OrderID = $orderId");
while($obj1 = mysqli_fetch_assoc($result1)) {
$menuId = $obj1['MenuID'];
$menuQty = $obj1['menuQty'];
$result2 = $mysqli->query("SELECT * FROM menu WHERE MenuID = $menuId");
$obj2 = mysqli_fetch_assoc($result2);
$name = $obj2['MenuName'];
$price = $obj2['MenuPrice'];
?>
<tr>
<th>Menu Name: <?php echo $name;?></th>
<th>Menu Price: <?php echo $price;?></th>
<th>Menu Quantity: <?php echo $menuQty;?></th>
</tr>
<?php } ?>
<tr>
<td><a href="update_order.php?id=<?php echo $orderId;?>">Update Order Total</a></td>
</tr>
<?php } ?>
</table>