-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproduct_category.php
112 lines (90 loc) · 3.93 KB
/
product_category.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
<?php
include('top_header.php');
echo "<title>products</title>";
include('connection.php');
include('header.php');
?>
<?php
if(!$_GET['cid']){
echo "<script language='javascript'>
document.location='product.php';
</script>";
}
if(isset($_GET['action'])&& $_GET['action'] ="add" ){
$id = intval($_GET['id']);
if(isset($_SESSION['cart'][$id])){
$_SESSION['cart'][$id]['quantity']++;
echo "<script language='javascript'>
document.location='product.php';
</script>";
}else {
$sql = "select * from products where id={$id} ";
$res = mysqli_query($conn,$sql);
if(!$res){
die("Error in conection to products".mysqli_error($conn));
}
if(mysqli_num_rows($res)){
$row = mysqli_fetch_assoc($res);
$_SESSION['cart'][$row['id']]=array("quantity" => 1, "price" => $row['product_price']);
echo "<script language='javascript'>
document.location='product.php';
</script>";
}else {
echo "Invalidate product Id";
}
}
}
?>
<center>
<div class="container-fluid " >
<div class="col-md-9">
<div class=" col-md-7 col-sm-12">
<img src="images\our-products.jpg" alt="" width="100%" height="100%">
</div>
<div class="alert alert-primary" role="alert" style="height:40px">
<h5 class="">
<?php
$cid = intval($_GET['cid']);
$sql="SELECT * FROM `category` WHERE `id`=$cid ";
$res = mysqli_query($conn,$sql);
if(!$res){
die("Error in the Cotegory ".mysqli_error($conn));
}
$rowc= mysqli_fetch_assoc($res);
echo $rowc['category_name'];?><h5>
</div>
<div class="row" align="center">
<?php
$sql = "SELECT * FROM `products` WHERE `category_id` = $cid";
$res=mysqli_query($conn,$sql);
if(!$res){
die("Error in image".mysqli_error($conn));
}
while($row = mysqli_fetch_assoc($res)){ ?>
<div class="col-md-4 sm-12">
<div class="card btn " id="product" style="margin:20px; padding:5px;">
<a href="product_details.php?pid=<?php echo "".$row['id']; ?>" > <img src="upload \<?php echo "".$row['product_image']; ?>" class="card-img-top" alt="..."></a>
<div class="card-body">
<h4><a style="text-decoration:none" href="product_details.php?pid=<?php echo "".$row['id']; ?>" ><?php echo "".$row['product_name']; ?></a></h4>
<!-- <p class="card-text"><a style="text-decoration:none" href="product_details.php?pid=<?php echo "".$row['id']; ?>" ><?php echo "".$row['product_description']; ?></a></p> -->
<div class="row">
<label class="col-6" ><a style="text-decoration:none" href="product_details.php?pid=<?php echo "".$row['id']; ?>" ><span class="
color: #fff;
text-decoration: none;">price</span></a></label>
<label class="col-6"><a style="text-decoration:none" href="product_details.php"><?php echo "".$row['product_price']; ?></a></label>
</div>
<div class="row">
<a style="width:50%" href="product.php?page=product&action=add&id=<?php echo $row['id']; ?>" class="lnk btn btn-primary" type="submit"><i class="icon fa fa-shopping-cart" style="margin-right:10px;"></i>Add to Cart</a>
<a style="width:50%" href="product.php?page=product&action=fav&id=<?php echo $row['id']; ?>" class="lnk btn btn-primary" type="submit"><i class="icon fa fa-heart-o" style="margin-right:10px;"></i>Favorits</a>
</div>
</div>
</div>
</div>
<?php } ?>
</div>
</div>
</div>
</center>
<?php
include("footer.php");
?>