forked from muriuki92/cestas-trial
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadmin.php
129 lines (107 loc) · 3.31 KB
/
admin.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
125
126
127
128
129
<?php include('header.php'); ?>
<?php
include 'dbcon.php';
?>
<style>
.box-container {
display: flex;
flex-wrap: wrap;
}
.box {
width: calc(33.33% - 20px);
margin: 10px;
}
body {
display: flex;
flex-direction: column;
align-items: center;
font-size: 14px;
}
table {
border-collapse: collapse;
width: 100%;
}
th {
background-color: black;
color: white;
text-align: left;
padding: 8px;
}
td {
border-bottom: 1px solid #ddd;
padding: 8px;
}
</style>
<body>
<!--header section starts-->
<header>
<div class="header-1">
<a href="#" style="" class="logo"><i class="fa-solid fa-basket-shopping"></i></i>Cesta- Admin Panel</a>
<form action="" class="search-box-container">
</form>
</div>
<!--header 2-->
<div class="header-2 " style="width: 1360px;">
<div id="menu-bar" class="fa-sharp fa-solid fa-bars"></div>
<nav class="navbar">
<a href="admin.php" style="" class="nav-link active">Dashboard</a>
<a href="addproduct.php" style="" class="nav-link active">Add Products</a>
<a href="orders.php" style="" class="nav-link active">No of orders</a>
<a href="index.php" style="" class="nav-link active">Home</a>
</nav>
<div class="icons">
<a href="cart.php" class="fa-sharp fa-solid fa-cart-shopping">
<?php
$countSql = "SELECT COUNT(*) AS total_items FROM cart";
$results = mysqli_query($dbconn, $countSql);
$rows = mysqli_fetch_assoc($results);
$totalItems = $rows['total_items'];
echo '<span style="color: #2c2c54; font-size: 15px; margin-top: 50px; border-radius: 50%;">' . $totalItems . '</span>';
?>
</a>
<?php
session_start();
if (isset($_SESSION['loggedIn'])) {
} else {
echo '<a href="signup.php" class="fa-sharp fa-solid fa-circle-user"></a>';
}
?>
</div>
</div>
</header>
<!--header section ends-->
<table>
<tr>
<th>id</th>
<th>name</th>
<th>newprice</th>
<th>oldprice</th>
<th>image</th>
<th>type</th>
<th>Action</th>
</tr>
<?php
$connect = "SELECT * FROM products";
$query = mysqli_query($dbconn, $connect);
// Loop through the fetched data and populate the table rows
while ($row = mysqli_fetch_assoc($query)) {
echo '<tr>';
echo '<td>' . $row['id'] . '</td>';
echo '<td>' . $row['name'] . '</td>';
echo '<td>' . $row['newprice'] . '</td>';
echo '<td>' . $row['oldprice'] . '</td>';
echo '<td><img style="width: 40px; height: 40px;" src="images/' . $row['image'] . '"></td>';
echo '<td>' . $row['type'] . '</td>';
echo '<td>
<button style="color: white; background-color: green; padding: 5px; border-radius: 5px;"><a style="color: white;" href="edit.php?id=' . $row['id'] . '">Edit</a></button>
<button style="color: white; background-color: red; padding: 5px; border-radius: 5px;"><a style="color: white;" href="delete.php?id=' . $row['id'] . '">Delete</a><?button>
</td>';
echo '</tr>';
}
?>
</table>
<!--js file link-->
<script src="js/script.js"></script>
<script src="bootstrap-5.3.0-alpha1-dist/bootstrap.min.js"></script>
</body>
</html>