-
Notifications
You must be signed in to change notification settings - Fork 0
/
getOrderlist.php
147 lines (99 loc) · 3.76 KB
/
getOrderlist.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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
<?php
if (session_status() == PHP_SESSION_NONE) { // initialize session to retain shopping cart info
session_start();
}
$_SESSION["isMember"] = true;
//".$_SESSION['uname']."
//$name = $_POST['uname'];
$name= $_SESSION["userName"];
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "cookiepassion";
$conn = mysqli_connect($servername, $username, $password, $dbname);
// Check connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
//else{ echo "connect success"; }
// here change last line "$name" to SESSION[username]
$all="SELECT userorder.orderTime, orderdetail.amount,userorder.orderId,userorder.total, orderdetail.id, cookie.name, cookie.description, cookie.price, cookie.imageLocation FROM userorder INNER JOIN orderdetail ON userorder.orderId = orderdetail.orderId INNER JOIN cookie ON orderdetail.cookieID = cookie.id WHERE userorder.username='".$name."'";
$u_orderId ="SELECT * from userorder where username='".$name."'";
$uo_result = mysqli_query($conn, $all);
$o_result = mysqli_query($conn, $u_orderId);
?>
<!DOCTYPE html>
<html>
<head>
<title></title>
<!-- external files -->
<link rel="stylesheet" href="css/styles.css" />
<script src="https://code.jquery.com/jquery-3.5.1.min.js" integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0=" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-ho+j7jyWK8fNQe+A12Hb8AhRq26LrZ/JpcUGGOn+Y7RsweNrtN/tE3MoK7ZeZDyx" crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" integrity="sha384-TX8t27EcRE3e/ihU7zmQxVncDAy5uIKz4rEkgIXeMed4M0jlfIDPvg6uqKI2xXr2" crossorigin="anonymous">
<!--script src="js/store.js" async></script>
<script src="js/edit.js" async></script>
<script src="js/jquery.cookie.js"></script-->
<style type="text/css">
img {
padding-left: 60px;
max-width: 300px;
height: 180px;
}
p1,p2{
font-size: 30px;
padding-left: 50px;
}
h3,h4{
font-weight: bold;
}
h2,h3,h4{
padding-left: 50px;
color: black;
}
</style>
</head>
<body>
<?php
include("headerNavbar.php");
?>
<h1 style="text-align: center; font-weight: bold;"> Your Order History</h1>
<?php
while($row0 = mysqli_fetch_array($o_result,MYSQLI_ASSOC)){
$order_id_1[]=$row0['orderId'];
$order_total_1[]=$row0['total'];
$order_time_1[]=$row0['orderTime'];
}
$orderDet = array();
while($row = mysqli_fetch_array($uo_result,MYSQLI_ASSOC)){
if (!array_key_exists($row['orderId'], $orderDet)) {
$orderDet[$row['orderId']] = array();
}
$tempArray = array();
$tempArray['imageLocation'] = $row['imageLocation'];
$tempArray['name'] = $row['name'];
$tempArray['price'] = $row['price'];
$tempArray['amount'] = $row['amount'];
array_push($orderDet[$row['orderId']], $tempArray);
}
//-*--------------**-----------*------------*------
$num_t = mysqli_num_rows($uo_result);
$num_i = mysqli_num_rows($o_result);
//print_r();
$currentIndex = 0;
for ($i=$num_i-1; 0 <= $i; $i--) {
# code..
echo "<h1> Order Number: ".$order_id_1[$i].", Total Price: $".$order_total_1[$i].", Order Date: ".$order_time_1[$i]."</h1>";
//echo "<h1> Total Price: ".$order_total_1[$i]."</h1>";
echo "<hr/>";
foreach ($orderDet[$order_id_1[$i]] as $arrRow) {
echo "<img class='o_img' src=". $arrRow['imageLocation']." >";
echo "<p1>Name: ". $arrRow['name']."</p1>";
echo "<p1>Price: ". $arrRow['price']."</p1>";
echo "<p1>Amount: ". $arrRow['amount']."</p1>";
echo "<hr/>";
}
}
?>
</body>
</html>