-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlist_orders.php
More file actions
151 lines (120 loc) · 4.21 KB
/
list_orders.php
File metadata and controls
151 lines (120 loc) · 4.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
<?php
$servername = "localhost";
$db_username = "your_db_username";
$db_password = "your_db_password";
$dbname = "mbzstore";
$conn = mysqli_connect('localhost', 'root', '', 'mbzstore');
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
};
include 'common_functions.php';
session_start();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Members</title>
<link rel="icon" href="WhatsApp Image 2023-03-13 at 15.14.46_auto_x2 (1).png">
<link rel="stylesheet" href="members.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="https://maxst.icons8.com/vue-static/landings/line-awesome/line-awesome/1.3.0/css/line-awesome.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css">
<style>
.product_img{
width: 20%;
object-fit: contain;
}
</style>
</head>
<body>
<?php include 'dashboard_header.php'; ?>
<div class="container">
<?php include 'sidebar.php'; ?>
<div class="content">
<h2>All Orders <i class="fa-solid fa-people-roof"></i></h2>
<div class="table-container">
<table>
<thead>
<?php
// Database connection and other includes...
// Query to fetch orders with associated usernames
$get_orders_query = "SELECT * FROM `user_orders`";
$result = mysqli_query($conn, $get_orders_query);
if ($result) {
$row_count = mysqli_num_rows($result);
echo "
<tr>
<th>S/N</th>
<th>Due Amount</th>
<th>Invoice Number</th>
<th>Total Products</th>
<th>Order Date</th>
<th>Status</th>
<th>User</th>
</tr>
";
if ($row_count == 0) {
echo "<p>No orders yet</p>";
} else {
$number = 0;
while ($row_data = mysqli_fetch_assoc($result)) {
$order_id = $row_data['order_id'];
$user_id = $row_data['user_id'];
$amount_due = $row_data['amount_due'];
$invoice_number = $row_data['invoice_number'];
$total_products = $row_data['total_products'];
$order_date = $row_data['order_date'];
$order_status = $row_data['order_status'];
$number++;
$get_username_query = "SELECT username FROM user_table WHERE user_id = $user_id";
$username_result = mysqli_query($conn, $get_username_query);
if ($username_result && mysqli_num_rows($username_result) > 0) {
$username_row = mysqli_fetch_assoc($username_result);
$username = $username_row['username'];
echo "<tr class='text-center'>
<td>$number</td>
<td>$amount_due</td>
<td>$invoice_number</td>
<td>$total_products</td>
<td>$order_date</td>
<td>$order_status</td>
<td>$username</td>
</tr>";
} else {
echo "<tr class='text-center'>
<td>$number</td>
<td>$amount_due</td>
<td>$invoice_number</td>
<td>$total_products</td>
<td>$order_date</td>
<td>$order_status</td>
<td>User Not Found</td>
</tr>";
}
}
}
} else {
echo "Error fetching orders: " . mysqli_error($conn);
}
?>
</tbody>
</table>
</div>
<?php include 'nav.php'; ?>
</div>
<script src="mebers.js"></script>
<script>
function toggleSidebar() {
var sidebar = document.getElementById("sidebar");
sidebar.classList.toggle("sidebar-expanded");
var navbar = document.getElementById("navbar");
navbar.classList.toggle("navbar-expanded");
var content = document.querySelector(".content");
content.classList.toggle("content-shifted");
}
</script>
</body>
</html>