-
Notifications
You must be signed in to change notification settings - Fork 2
/
items.php
61 lines (59 loc) · 2.3 KB
/
items.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
<?php
include './config.php';
if(isset($_SESSION['user'])){
include './navigasi.php';
}
$SQL1= mysql_query("select * from items");
echo "<h3>Produk</h3>";
if(isset($_REQUEST['atc'])){
$item_id=$_REQUEST['itemcart'];
$personq=$_SESSION['user'];
$sqlpersonq= mysql_query("select * from users where username='$personq'");
$prowq=mysql_fetch_object($sqlpersonq);
$person_idq=$prowq->id;
$cek= mysql_query("select * from addtocart where item_id='$item_id' and person_id='$person_idq' and isEnd='n'");
$rw= mysql_fetch_object($cek);
$harga=$_REQUEST['itemharga'];
$person=$_SESSION['user'];
$sqlperson= mysql_query("select * from users where username='$person'");
$prow=mysql_fetch_object($sqlperson);
$person_id=$prow->id;
$null=0;
if($person!=null){
if($rw->person_id==$person_id){
if($rw->qty>=1 ){
$ce1= mysql_query("select * from addtocart where item_id='$item_id' and person_id='$person_id' and isEnd='n'");
$ob= mysql_fetch_object($ce1);
$pr=$ob->qty+1;
$up=mysql_query("UPDATE addtocart SET qty = '$pr' where item_id='$item_id' and person_id='$person_id'");
}else{
$sqlin=mysql_query("insert into addtocart values('','$item_id','1','$harga','$person_id','n','$null')");
}
}else{
$sqlin=mysql_query("insert into addtocart values('','$item_id','1','$harga','$person_id','n','$null')");
}
if($sqlin or $up){
// echo "<div style='border-color: #ccff33;background-color: #00cc00'>";
// echo "1 Barang di tambah ke keranjang belanja";
// echo "</div>";
echo"<script>alert('1 Barang di tambah ke keranjang belanja');</script>";
}}else{
echo"<script>alert('silahkan login untuk menambah item');</script>";
}
}
while ($row = mysql_fetch_array($SQL1)) {
?>
<table>
<tr>
<td><?php echo $row['nama_items']; ?></td>
<td>
<form method="post">
<input type="hidden" name="itemcart" value="<?php echo $row['id'];?>">
<input type="hidden" name="itemharga" value="<?php echo $row['harga'];?>">
<input type="submit" value="Add to Cart" name="atc">
</form>
</td>
</tr>
</table>
<?php } ?>
<a href="cart.php"><input type="submit" value="Lihat Keranjang Belanja"></a>