-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathadmin_users.php
124 lines (107 loc) · 5.17 KB
/
admin_users.php
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
<?php
include_once "includes/covaid_database.php";
$page = "Users";
include("includes/admin_header.php");
$result = mysqli_query($conn, "SELECT * FROM user_info");
$num_rows = mysqli_num_rows($result)-1;
$totalPurchase = 0; //Unknown
$sql2 = "SELECT COUNT(userID) AS num_purchase FROM user_order;";
$result2 = mysqli_query($conn, $sql2);
$resultCheck2 = mysqli_num_rows($result2);
if ($resultCheck2 > 0) {
$row2 = mysqli_fetch_assoc($result2);
$totalPurchase = $row2['num_purchase'];
}
?>
<main class="main_content">
<header class="header">
<ion-icon name="people-outline" class="header-icon"></ion-icon>
<span class="header-name">Users</span>
</header>
<div class="wrapper-grid layout2" id=scroll-1>
<div class="half-page1" style="text-align: center; background: rgb(115,14,197);
background: linear-gradient(90deg, rgba(115,14,197,1) 0%, rgba(154,92,205,1) 43%, rgba(200,169,225,1) 100%);">
<span style="font-size: xx-large; color: white;">
Number of users: <?php echo $num_rows?>
</span>
</div>
<div class="half-page2" style="background: rgb(8,0,154);
background: linear-gradient(90deg, rgba(8,0,154,1) 0%, rgba(14,14,156,1) 35%, rgba(0,178,214,1) 100%);">
<span style="font-size: xx-large; color: white;">
Total number of purchases: <?php echo $totalPurchase?>
</span>
</div>
<div class="full-page ">
<table class="user-table table-sortable">
<thead>
<tr>
<th>Email</th>
<th>First name</th>
<th>Last name</th>
<th>Phone number</th>
<th>Total purchase</th>
</tr>
</thead>
<tbody>
<?php
//Retrieve all user info from the database
$user_email = "---";
$user_firstname = "---";
$user_lastname = "---";
$user_phone = "---";
$user_id;
$sql = "SELECT * FROM user_info;";
$result = mysqli_query($conn, $sql);
$resultCheck = mysqli_num_rows($result);
//Makes sure that the connection was established
if ($resultCheck > 0) {
while ($row = mysqli_fetch_assoc($result)) {
$user_email = $row['user_id'];
$user_firstname = $row['user_first'];
$user_lastname = $row['user_last'];
$user_id = $row['id'];
$user_phone = $row['phone1'];
$numPurchase = 0; //Unknown
$sql1 = "SELECT COUNT(userID) AS num_purchase FROM user_order WHERE userID = '$user_email';";
$result1 = mysqli_query($conn, $sql1);
$resultCheck1 = mysqli_num_rows($result1);
if ($resultCheck1 > 0) {
$row1 = mysqli_fetch_assoc($result1);
$numPurchase = $row1['num_purchase'];
}
if($user_id != 39){
print("<tr><td>$user_email</td>");
if ($user_firstname != "") {
print("<td>$user_firstname</td>");
} else {
print("<td>---</td>");
}
if ($user_lastname != "") {
print("<td>$user_lastname</td>");
} else {
print("<td>---</td>");
}
if ($user_phone != "") {
print("<td>$user_phone</td>");
} else {
print("<td>---</td>");
}
print("<td>$numPurchase</td></tr>");
}
$user_email = "---";
$user_firstname = "---";
$user_lastname = "---";
$user_phone = "---";
}
}
?>
</tbody>
</table>
</div>
</div>
</main>
<!-- JS script-->
<script src="https://unpkg.com/ionicons@5.2.3/dist/ionicons.js "></script>
<script src="js/admin.js "></script>
</body>
</html>