-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcategory.php
More file actions
187 lines (170 loc) · 6.28 KB
/
category.php
File metadata and controls
187 lines (170 loc) · 6.28 KB
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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
<?php
include_once("header.php");
include('hms/include/config.php');
?>
<!-- Section -->
<section class="hero3">
<a href="./index.php">HOME</a>/<a href="">SHOP</a>
<?php
$idtext=$_GET['viewid'];
$catslug=mysqli_query($con,"select catname,catslug from category where id='$idtext'");
$row1=mysqli_fetch_array($catslug);
?>
<h2><?php echo $row1['catname'] ?></h2>
</section>
<div class="sel">
<div class="container">
<div class="row">
<?php
$procat=$row1['catslug'];
$sql=mysqli_query($con,"select * from product where procat='$procat'");
while($row=mysqli_fetch_array($sql))
{
?>
<div class="col-xs-12 col-md-12 col-ds-3 col-lg-3">
<div class="card bs">
<img src="hms/images/<?php echo $row['proimg'];?>" class="card-img-top" alt="Image of <?php echo htmlspecialchars($row['proname']); ?>" height="200px">
<div class="card-body">
<h5 class="card-title"><?php echo htmlspecialchars($row['proname']); ?>
</h5>
<b>Rs. <?php echo $row['proprice'];?></b>
<a href="desc.php?id=<?php echo $row['id']; ?>"><button>Make Order</button></a>
<form class="form-submit">
<input type="hidden" class="pname" value="<?php echo $row['proname'];?>">
<input type="hidden" class="pprice" value="<?php echo $row['proprice'];?>">
<input type="hidden" class="pimage" value="<?php echo $row['proimg'];?>">
<input type="hidden" class="pcode" value="<?php echo $row['id'];?>">
<!-- <a href="cart.php?id=<?php echo $row['id']; ?>"><button>Add To Cart</button></a> -->
<!-- <button id="addItem" class="addItem btn-success btn button" style="background-color:green;">Add To Cart</button> -->
<div class="alert-message"></div>
</form>
</div>
</div>
</div>
<!-- <div class="col-xs-12 col-md-12 col-ds-3 col-lg-3">
<div class="card bs">
<img src="Images/LycheeRoseStrawberry.jpg" class="card-img-top" alt="..." height="200px">
<div class="card-body">
<h5 class="card-title">Litchi Strawberry</h5>
<b>Rs. 1,100.00</b>
<a href=""><button>Add To Cart</button></a>
<a href="./White-Strawberry.php"><button>Make Order</button></a>
</div>
</div>
</div>
<div class="col-xs-12 col-md-12 col-ds-3 col-lg-3">
<div class="card bs">
<img src="Images/LycheeCherryChantilly.jpg" class="card-img-top" alt="..." height="200px">
<div class="card-body">
<h5 class="card-title">Litchi Cherry Parfait</h5>
<b>Rs. 550.00</b>
<a href=""><button>Add To Cart</button></a>
<a href="./Litchi-Cherry-Parfait.php"><button>Make Order</button></a>
</div>
</div>
</div>
<div class="col-xs-12 col-md-12 col-ds-3 col-lg-3">
<div class="card bs">
<img src="Images/lycheeCherryChantilly2.jpg" class="card-img-top" alt="..." height="200px">
<div class="card-body">
<h5 class="card-title">Litchi Craquelin</h5>
<b>Rs. 750.00</b>
<a href=""><button>Add To Cart</button></a>
<a href="./Litchi-Au-Craquelin.php"><button>Make Order</button></a>
</div>
</div>
</div>-->
<?php } ?>
</div>
</div>
</div>
<?php
include_once("footer.php");
?>
<script>
$(document).ready(function(){
$(document).on('click','#addItem',function(e){
e.preventDefault();
// it find the nearest form when we clicking on button
var form=$(this).closest(".form-submit");
var pcode=form.find('.pcode').val();
var pname=form.find('.pname').val();
var pimage=form.find('.pimage').val();
var pprice=form.find('.pprice').val();
//var $this = $(this);
var alertmsg=form.find('.alert-message');
$.ajax({
url:'action.php',
method:'post',
data:{pcode:pcode,pname:pname,pimage:pimage,pprice:pprice},
success:function(response){
console.log(response);
alertmsg.html(response);
// $this.closest('.alert-message').html(response)
//$(this).closest('.alert-message').html(response);
//alertmsg.html(response);
//window.scrollto(0,0);
load_cart_item_number();
}
});
});
load_cart_item_number();
function load_cart_item_number(){
$.ajax({
url:'action.php',
method:'get',
// cart_item is a parameter pass to the load_cart_item_number()
data:{cartItem:"cart_item"},
success:function(response){
$("#cart-item").html(response);
}
});
}
});
$(document).on('click','.addItem',function(e){
// ...
});
</script>
<script>
$(document).ready(function() {
// Add to cart
$(document).on('click', '#addItem', function(e) {
e.preventDefault();
var form = $(this).closest(".form-submit");
var pcode = form.find('.pcode').val();
var pname = form.find('.pname').val();
var pimage = form.find('.pimage').val();
var pprice = form.find('.pprice').val(); // MRP
var pdiscount = form.find('.pdiscount').val(); // Discounted
var alertmsg = form.find('.alert-message');
$.ajax({
url: 'action.php',
method: 'POST',
data: {
pcode: pcode,
pname: pname,
pimage: pimage,
pprice: pprice,
pdiscount: pdiscount
},
success: function(response) {
alertmsg.html(response).fadeIn().delay(2000).fadeOut();
load_cart_item_number();
}
});
});
// Load cart item count
function load_cart_item_number() {
$.ajax({
url: 'action.php',
method: 'GET',
data: { cartItem: "cart_item" },
success: function(response) {
$("#cart-item").html(response);
}
});
}
load_cart_item_number();
});
</script>
<!-- category.php file -->