-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcategories.php
More file actions
131 lines (101 loc) · 3.36 KB
/
categories.php
File metadata and controls
131 lines (101 loc) · 3.36 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
<?php include("partials-front/menue.php") ?>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<!-- CAtegories Section Starts Here -->
<section class="categories">
<div class="container">
<h2 class="text-center">Explore Foods</h2>
<?php
//Display all the cateories that are active
//Sql Query
$sql = "SELECT * FROM tbl_category WHERE active='Yes'";
//Execute the Query
$res = mysqli_query($conn, $sql);
//Count Rows
$count = mysqli_num_rows($res);
//CHeck whether categories available or not
if($count>0)
{
//CAtegories Available
while($row=mysqli_fetch_assoc($res))
{
//Get the Values
$id = $row['id'];
$title = $row['title'];
$image_name = $row['image_name'];
?>
<a href="<?php echo SITEURL; ?>category-foods.php?category_id=<?php echo $id; ?>">
<div class="box-3 float-container">
<?php
if($image_name=="")
{
//Image not Available
echo "<div class='error'>Image not found.</div>";
}
else
{
//Image Available
?>
<img src="<?php echo SITEURL; ?>images/category/<?php echo $image_name; ?>" alt="Pizza" class="img-responsive img-curve">
<?php
}
?>
<h3 class="float-text text-white"><?php echo $title; ?></h3>
</div>
</a>
<?php
}
}
else
{
//CAtegories Not Available
echo "<div class='error'>Category not found.</div>";
}
?>
<div class="clearfix"></div>
</div>
</section>
<!-- Categories Section Ends Here -->
<script type="text/javascript">
$(document).ready(function(){
$(".addItemBtn").click(function(e){
e.preventDefault();
var $form=$(this).closest(".form-submit");
var pid=$form.find(".pid").val();
var ptitle=$form.find(".ptitle").val();
var pPrice=$form.find(".pPrice").val();
var pimage=$form.find(".pimage").val();
var pcode = $form.find(".pcode").val();
$.ajax({
url:'action.php',
method:'post',
data:{pid:pid,ptitle:ptitle,pPrice:pPrice,pimage:pimage,pcode:pcode},
success:function(response){
$("#message").html(response);
if (response.includes('Item Added to your cart!')) {
$("#message").addClass('success');
window.scrollTo(0,0);
load_cart_item_number();
} else {
$("#message").addClass('error');
}
$("#message").fadeIn();
setTimeout(function() {
$("#message").fadeOut();
}, 5000);
}
});
});
load_cart_item_number();
function load_cart_item_number(){
$.ajax({
url:'action.php',
method:'get',
data:{cartItem:"cart_item"},
success:function(response){
$("#cart-item").html(response);
}
});
}
});
</script>
<?php include('partials-front/footer.php') ?>