-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcart.php
144 lines (105 loc) · 4.26 KB
/
cart.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
<?php
require 'customer.php';
?>
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="cart.css">
<title></title>
</head>
<body>
<div class="showCart">
<form class="abc" method="post">
<table class="center" border="1">
<tr>
<!-- <th>select</th>-->
<th>Product ID</th>
<th>Category</th>
<th>Price</th>
<th>Food</th>
<th>Image </th>
<th>Quantity </th>
<th>ORDER</th>
<th>REMOVE</th>
</tr>
<?php
$user=$_SESSION["vemail"];
$i=1;
$c=1;
$sql = mysqli_query($conn,"SELECT * FROM cart WHERE cart_by='$user'");
if (mysqli_num_rows($sql)>0) {
while ($row=mysqli_fetch_assoc($sql)) {
$img =$row['image'];
$rid = $row['id'];
echo "<tr>";
// echo "<td><input type='checkbox' name=select[] value=' $rid'></td>";
echo "<td>".$row['id']."</td>";
//echo '<input type="hidden"name="id" value=".$rid.">';
echo "<td>".$row['category']."</td>";
echo "<td>".$row['food']."</td>";
echo "<td>".$row['price']."</td>";
echo "<td><img src='image/$img' height='200' width='200' style='padding:0,margin:1vh 1vw;'></td>";
echo "<form method=post>";
echo "<td><input type='number' name='count' value='0' style='float:right;margin-bottom:1vh;margin-right:1vw;margin-left:5px;' required></td>";
echo "<td><input type='submit' value='Order Now' name='order$i' style='float:right;margin-bottom:1vh;margin-right:1vw;margin-left:10px;'></td>";
echo "<td><input type='submit' value='delete' name='delete$i' style='float:right;margin-bottom:1vh;margin-right:1vw;margin-left:10px;'></td>";
echo "</form>";
if (isset($_POST["order$i"])) {
$user = $_SESSION["vemail"];
$id = $row['id'];
$_SESSION['id1']=$id;
$fid = $row['fid'];
$_SESSION['fid1']=$fid;
$cat = $row['category'];
$_SESSION['category1']=$cat;
$food = $row['food'];
$_SESSION['food1']=$food;
$price = $row['price'];
$_SESSION['price1']=$price;
$count = $_POST['count'];
$_SESSION['count1']=$count;
$total1= $price*$count;
$_SESSION['total1']=$total1;
$img1= $row["image"];
$_SESSION['image1']= $img1;
if ($count>0) {
// header("Location: checkout.php");
echo "<script> window.location.replace('checkout.php')</script>";
}
else {
echo "select quantity please";
}
}
//delete from cart
if (isset($_POST["delete$i"])) {
$user = $_SESSION["vemail"];
$id = $row['id'];
$_SESSION['id1']=$id;
$fid = $row['fid'];
$_SESSION['fid1']=$fid;
$food = $row['food'];
$_SESSION['food1']=$food;
$price = $row['price'];
$_SESSION['price1']=$price;
// $count = $_POST['count'];
// $total1= $price*$count;
// $_SESSION['total1']=$total1;
$del = mysqli_query($conn, "DELETE FROM cart WHERE id ='$id' ");
}
// order all
echo "</tr>";
echo "<br>";
$i++;
}
}
?>
</tr>
</table>
<input type="submit" name="order" value="ORDER NOW">
<?php
?>
</form>
</div>
</body>
</html>