forked from walteranyika/movie-store
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsales.php
82 lines (72 loc) · 2.72 KB
/
sales.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
<?php
include 'protect.php';
require 'connect.php';
$sql = "SELECT * FROM products";
$result = mysqli_query($con, $sql) or die(mysqli_error($con));// executing the query
$rows = mysqli_fetch_all($result, 1);//assoc array
mysqli_close($con);//close the connection
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Users</title>
<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.24/css/jquery.dataTables.min.css">
</head>
<body>
<?php include 'nav.php' ?>
<div class="container">
<div class="row justify-content-center">
<div class="col-sm-10">
<?php
// $movie_count = count($_SESSION["products"]);
if (isset($_SESSION["products"]))
$movie_count = count(array_unique($_SESSION["products"]));
?>
<div class="row border mt-2 mb-2 p-2">
<div class="col-6 m-auto text-center">
You have <?= $movie_count ?? 0 ?> movies in the cart.
</div>
<div class="col-6 text-center">
<a href="checkout.php" class="btn btn-success btn-sm">Checkout</a>
</div>
</div>
<table id="example" class="table table-striped table-bordered">
<thead>
<tr>
<th>TITLE</th>
<th>GENRE</th>
<th>DESCRIPTION</th>
<th>POSTER</th>
<th>ACTION</th>
</tr>
</thead>
<tbody>
<?php foreach ($rows as $movie): ?>
<tr>
<td> <?= $movie["title"] ?> </td>
<td> <?= $movie["genre"] ?> </td>
<td> <?= $movie["description"] ?> </td>
<td><img src="<?= $movie['poster'] ?>" width="60" height="60" alt="<?= $movie["title"] ?>"></td>
<td><a class="btn btn-info btn-sm" href="add-to-cart.php?id=<?= $movie["id"] ?>">Add To Cart</a>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.5.1.js"></script>
<script src="https://cdn.datatables.net/1.10.24/js/jquery.dataTables.min.js"></script>
<script>
$(document).ready(function () {
$('#example').DataTable();
});
</script>
</body>
</html>