source: ActiveOrders.php

Last change on this file was e3d4e0a, checked in by Vlado 222039 <vlado.popovski@…>, 6 days ago

Upload project files

  • Property mode set to 100644
File size: 2.6 KB
Line 
1<?php
2 session_start();
3
4 require './connect.php';
5
6 $orders_res = mysqli_query($conn, "SELECT * FROM orders WHERE status = 'a'; ");
7?>
8
9<!DOCTYPE html>
10<html lang="en">
11 <head>
12 <meta charset="UTF-8">
13 <meta name="viewport" content="width=device-width, initial-scale=1.0">
14 <link rel="stylesheet" href="./CSS/AdminOrders.css">
15 <title>Active Orders</title>
16 </head>
17 <body>
18 <table class="container">
19 <tr class="header">
20 <th>Order Number</th>
21 <th>User ID</th>
22 <th>Order Date</th>
23 <th>Shipped Date</th>
24 <th>Price</th>
25 <th>City</th>
26 <th>Postal Code</th>
27 <th>Address</th>
28 <th></th>
29 <th></th>
30 </tr>
31 <?php
32
33 foreach($orders_res as $order) {
34 $order_price = 0;
35 $order_items = mysqli_query($conn, "SELECT * FROM order_item WHERE order_id={$order['id']};");
36
37 foreach($order_items as $item) {
38 $product_name = mysqli_query($conn, "SELECT name FROM products INNER JOIN order_item ON products.product_id = order_item.product_id WHERE order_item.id={$item['id']};")->fetch_assoc()['name'];
39 $order_price = $order_price + ($item['quantity']*$item['price']);
40 }
41 ?>
42 <tr>
43 <td><?php echo $order['id'] ?></td>
44 <td><?php echo $order['user_id'] ?></td>
45 <td><?php echo $order['order_date'] ?></td>
46 <td><?php echo $order['shipped_date'] ?></td>
47 <td>$<?php echo $order_price ?></td>
48 <td><?php echo $order['city'] ?></td>
49 <td><?php echo $order['postal_code'] ?></td>
50 <td><?php echo $order['address'] ?></td>
51 <td>
52 <a href='./ViewOrder.php?order_id=<?php echo $order['id'] ?>'>View</a>
53 </td>
54 <td>
55 <form action="./DeliverOrder.php" method="POST">
56 <input type="hidden" name="order_id" value="<?php echo $order['id'] ?>">
57 <button>Delivered</button>
58 </form>
59 </td>
60 </tr>
61 <?php
62 }
63
64 ?>
65 </table>
66 </body>
67</html>
Note: See TracBrowser for help on using the repository browser.