-
Notifications
You must be signed in to change notification settings - Fork 0
/
purchaseHistory.php
77 lines (68 loc) · 1.99 KB
/
purchaseHistory.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
<?php
/**
* Created by PhpStorm.
* User: msbomrel
* Date: 12/1/16
* Time: 7:31 AM
*/
session_start();
include ('include/connect.php');
if(isset($_SESSION['user'])){
$currentUser = $_SESSION['user'];
$sql = " select * from product JOIN checkout ON product.id = checkout.p_id WHERE uname = '$currentUser'";
$details = mysqli_query($conn, $sql);
if (mysqli_num_rows($details) == 0){
$nohistory = " You have not purchased anything Yet. Start Shopping";
}
}
?>
<!doctype html>
<html lang="en">
<head>
</head>
<body>
<?php
include ('header.php');
?>
<!---- content box--->
<div class="ui main container">
<?php if (!mysqli_num_rows($details) == 0){ ?>
<h1> Dear <?php echo $currentUser ?>,
You have purchased following products from Us</h1>
<?php } else {?> <h2> <?php echo $nohistory ?> </h2><?php }?>
<div class="ui fluid message">
<table border="1" class="ui table">
<thead>
<th>Product</th>
<th>Description</th>
<th>Price</th>
<th>Discount</th>
<th>Quantity</th>
<th>Total</th>
</thead>
<tbody>
<?php
$sum = 0;
while ($row = mysqli_fetch_assoc($details))
{
?>
<tr>
<td><?php echo $row["name"]; ?></td>
<td><?php echo $row["description"]; ?></td>
<td><?php echo $row["price"] ?></td>
<td><?php echo $row["discount"] ?></td>
<td><?php echo $row["qty"] ?></td>
<td><?php echo $row['qty']*($row['price'] - $row['discount']);
$sum = $sum + $row['qty']*($row['price'] - $row['discount']);
?></td>
</tr>
<?php }?>
<h3>Total sum : Rs<?php echo $sum ?> </h3>
</tbody>
</table>
</div>
</div>
<!----- footer------>
<?php include ('footer.php')?>
</body>
</html>