-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathordersummary.php
36 lines (33 loc) · 1.07 KB
/
ordersummary.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
<?php
session_start();
if (!(isset($_SESSION['username']))) {
header("Location: ../html/login.html");
}
include('conn.php');
$cartArray = $_POST['cartArray'];
$canteenname = $_SESSION['canteenname'];
$studentname = $_SESSION['name'];
$studentmobile = $_SESSION['mobile'];
$studentid = $_SESSION['id'];
$takeid = "select orderid from order_$canteenname order by id DESC limit 1 ; ";
$result = $conn->query($takeid);
if ($result->num_rows > 0) {
$r = $result->fetch_assoc();
$orderid = $r['orderid'] + 1;
} else
$orderid = 1;
$flag = false;
foreach ($cartArray as $key => $row) {
$itemid = $row['no'];
$itemname = $row['name'];
$count = $row['count'];
$price = $row['price'];
$total = $row['total'];
$sql = "insert into order_$canteenname(itemid, itemname, count, orderid, price, total, student_name, student_mobile, student_id, status)
values ('$itemid','$itemname','$count','$orderid','$price','$total','$studentname','$studentmobile','$studentid','0') ;";
if ($conn->query($sql)) {
$flag = true;
}
}
echo $flag;
$conn->close();