-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaccount.php
More file actions
136 lines (119 loc) · 5.42 KB
/
account.php
File metadata and controls
136 lines (119 loc) · 5.42 KB
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
<!DOCTYPE html>
<html lang =en>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no">
<title>php1004v2</title>
<link rel="stylesheet" href="./css/Bootstrap-DataTables.css">
<link rel="stylesheet" href="./css/Header-Dark.css">
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.20/css/dataTables.bootstrap4.min.css" crossorigin="anonymous">
<?php include './includes/bootstrap-header.php'; ?>
</head>
<body>
<?php include './includes/nav.php'; ?>
<div>
<div class="header-dark" style="background: url("https://i.imgur.com/Q4etkjd.png");min-height: 0;">
<br>
<br>
<br>
<div class="container hero">
<div class="row">
<div class="col-md-8 offset-md-2">
<div class="author"><img class="rounded-circle" src="./images/logos/cat.gif">
<h5 class="text-white name"><?php echo $_SESSION['name'] . " " . $_SESSION['last_name']?></h5>
<p class="text-white title"><?php echo ($_SESSION['isAdmin'] ? "Admin" : "User")?></p>
</div>
<hr>
<form action="accountEdit.php" method="get">
<button class="btn btn-primary" type="submit">Edit Profile</button>
</form>
</div>
</div>
</div>
</div>
</div><div class="bootstrap_datatables">
<div class="container py-5">
<header class="text-center text-black">
<h1 class="display-4">My Orders</h1>
</header>
<div class="row py-5">
<div class="col-lg-10 mx-auto">
<div class="card rounded shadow border-0">
<div class="card-body p-5 bg-white rounded">
<div class="table-responsive">
<table id="example" style="width:100%" class="table table-striped table-bordered">
<thead>
<tr>
<th>ID</th>
<th>Transaction Date</th>
<th>Charge ID</th>
<th>Sale Status</th>
<th>Car Count</th>
</tr>
</thead>
<tbody>
<?php
//order history READ
session_start();
$memberid = 1; //debug only
if (isset($_SESSION['memberid'])) {
$memberid = $_SESSION['memberid']; //for later use
}
else {
echo "<meta http-equiv='refresh' content='0;url=./login.php'>";
return;
}
$config = parse_ini_file('../../private/db-config.ini');
$conn = new mysqli($config['servername'], $config['username'], $config['password'], "project1004");
if ($conn->connect_error) {
$errorMsg = "Connection failed: " . $conn->connect_error;
echo $errorMsg;
$success = false;
}
else {
//$stmt = $conn->prepare("SELECT * FROM orders os, order_details ods where member_id = ? and os.id = ods.order_id");
//select id, chargeid, transaction date and count the number of cars in the order, groupby to allow count()
$stmt = $conn->prepare("SELECT os.id, charge_id, transaction_date, saleStatus, count(car_id) cars FROM orders os, order_detail od where member_id = ? and os.id = od.order_id group by os.id");
$stmt->bind_param("i", $memberid);
$stmt->execute();
$result = $stmt->get_result();
while($row = $result->fetch_assoc()) {
//$carid = $row["car_id"];
//$qty = $row["qty"];
//only need to show the order ids
$orderid = $row["id"];
$tdate = $row["transaction_date"];
$chargeid = $row["charge_id"];
$salestatus = $row["saleStatus"];
$totalCars = $row["cars"]; //count(car_id) cars
//write html here
?>
<tr>
<td><?php echo $orderid?></td>
<td><?php echo $tdate?></td>
<td><?php echo $chargeid?></td>
<td><?php echo $salestatus?></td>
<td><?php echo $totalCars?></td>
</tr>
<?php
}
}
//order history DELETE
?>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<script src="https://cdn.datatables.net/1.10.20/js/jquery.dataTables.min.js"></script>
<script src="https://cdn.datatables.net/1.10.20/js/dataTables.bootstrap4.min.js"></script>
<script src="./js/Bootstrap-DataTables.js"></script>
<?php
include "./includes/footer.php";
?>
</body>
</html>