-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwishlist.php
99 lines (98 loc) · 3.42 KB
/
wishlist.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
<?php require 'config.php' ?>
<?php require 'nav.php' ?>
<?php
if(!isset($_SESSION['username']))
{
if(isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on')
$url = "https://";
else
$url = "http://";
$url.= $_SERVER['HTTP_HOST'];
$url.= $_SERVER['REQUEST_URI'];
$_SESSION['back']=$url;
header('Location:'.'signin.php');
}
$accountid=$_SESSION['accountid'];
$sql="select cat.id as prodid,cat.name as name,cat.price as price,cat.imagename as img,car.id as id from grocerywishlist as car left join grocerycatalog as cat on car.pid=cat.id where car.custid=$accountid;";
$result=$conn->query($sql);
$noitems=$result->num_rows;
?>
<html>
<head>
<link rel="stylesheet" href="css/cart.css" type="text/css" />
</head>
<body onload="calcTotal()">
<div class="allitems">
<?php
while($row = $result->fetch_assoc())
{
$name=$row['name'];
$img=$row['img'];
$id=$row['id'];
$prodid=$row['id'];
$price=$row['price'];
$prodid=$row['prodid'];
$idq=$id."qty";
$idp=$id."price";
$idd=$id."dprice";
$idprod=$id."prod";
print <<< END
<div class="item" id="$id">
<div class="left">
<img src="images/products/$img">
</div>
<div id="$idprod" hidden>$prodid</div>
<div class="right">
<div class="row">
<div class="name">$name</div>
<div class="delete" onclick="deleteWish($id,$prodid)"><img src="images/icons/delete.png"></div>
</div>
<div class="row">
<div class="price">$<label id="$idd" class="dprice">$price</label></div>
</div>
<div class="row">
<div class="buybtn" onclick="view($prodid)">View</div>
</div>
</div>
</div>
END;
} ?>
</div>
<div class="totaldiv">
<div class="row">
<div class="noitems">Number of Items: <label id="itemcount"><?php echo $noitems; ?></label></div>
</div>
<div class="row">
<div class="grandtotal">Grand Total: <label>$</label><label id="gtotal"></label></div>
</div>
</div>
</body>
<script type="text/javascript">
function calcTotal()
{
var x = document.getElementsByClassName("dprice");
var i;
var total=0;
for (i = 0; i < x.length; i++) {
total+=parseFloat(x[i].innerHTML);
}
document.getElementById("gtotal").innerHTML=total;
}
function view(id)
{
window.location.replace("productpage.php?id="+id+"&qty=1");
}
function deleteWish(pid,id)
{
var obj=document.getElementById(pid);
obj.remove();
var count=parseFloat(document.getElementById("itemcount").innerHTML);
document.getElementById("itemcount").innerHTML=count-1;
calcTotal();
var xmlhttp = new XMLHttpRequest();
xmlhttp.open("GET","deletewish.php?id="+id, true);
xmlhttp.send();
//window.location.replace("deletecart.php?id="+pid);
}
</script>
</html>