-
Notifications
You must be signed in to change notification settings - Fork 0
/
cart.php
67 lines (63 loc) · 1.81 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
<?php
include 'connection.php';
include 'Header.html';
$query = "select * from cart,products where user_idcart =".$_SESSION["uid"]." and cart.product_idcart=products.id";
$totalPrice =0;
$result = mysqli_query($con,$query);
$i=0;
if (!$result) {
echo mysqli_error($result);
}
else {
if (mysqli_num_rows($result)==0) {
echo "No Products On Cart";
}
else {
?>
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="IndexCSS.css">
<link rel="stylesheet" href="ProductCSS.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<title></title>
</head>
<body>
<table id="catalog">
<tr>
<th> <i>product</i></th>
<th><i>price</i></th>
</tr>
<?php
while ($row=mysqli_fetch_assoc($result)) {
$product_id = $row["product_idcart"];
$product_name = $row["name"];
$product_price = $row["price"];
$product_cents = $row["cents"];
$allprice = $product_price + (0.01*$product_cents);
$totalPrice = $totalPrice+$allprice;
$arrayProducts[$i] = $product_id;
$i++;
?>
<tr>
<td><?=$product_name?></td>
<td> <span id="decimalfont"> <b><?=$product_price?></span>.<?=$product_cents?>€</b></td>
<td> <a href="removefromcart.php?id=<?=$product_id?>">remove from cart</a> </td>
</tr>
<?php
}
$pro = htmlentities(serialize($arrayProducts));
echo "<tr><td>Total price</td><td>".$totalPrice."</td></tr>";
echo"</table>";
?>
<br>
<form class="" action="purchaseCheck.php" method="get">
<button type="submit" name="prod" value="<?=$pro?>" class="Buttons"> Buy</button>
</form>
<?php
echo "</body>
</html>";
}
}
?>