-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathfunctions.php
More file actions
67 lines (65 loc) · 2.53 KB
/
Copy pathfunctions.php
File metadata and controls
67 lines (65 loc) · 2.53 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
<?php
require_once "db_connection.php";
function getPro(){
global $con;
$getProQuery = '';
if(!isset($_GET['cat']) && !isset($_GET['brand']) && !isset($_GET['search'])){
$getProQuery = "select * from products order by RAND();";
}
else if(isset($_GET['cat'])){
$pro_cat_id = $_GET['cat'];
$getProQuery = "select * from products where pro_cat = '$pro_cat_id'";
}
else if(isset($_GET['brand'])){
$pro_brand_id = $_GET['brand'];
$getProQuery = "select * from products where pro_brand = '$pro_brand_id'";
}
else if(isset($_GET['search'])){
$user_query = $_GET['search'];
$getProQuery = "select * from products where pro_keywords like '%$user_query%'";
}
$getProResult = mysqli_query($con,$getProQuery);
$count_pro = mysqli_num_rows($getProResult);
if($count_pro==0){
echo "<h4 class='alert-warning align-center my-2 p-2'> No Product found in selected criteria </h4>";
}
while($row = mysqli_fetch_assoc($getProResult)){
$pro_id = $row['pro_id'];
$pro_title = $row['pro_title'];
$pro_price = $row['pro_price'];
$pro_image = $row['pro_image'];
echo "
<div class='col-sm-6 col-md-4 col-lg-3 text-center product-summary'>
<h5 class='text-capitalize'>$pro_title</h5>
<img src='product_images/$pro_image' class='img-fluid'>
<p> <b> Rs $pro_price/- </b> </p>
<a href='detail.php' class='btn btn-info btn-sm'>Details</a>
<a href='#'>
<button class='btn btn-primary btn-sm'>
<i class='fas fa-cart-plus'></i> Add to Cart
</button>
</a>
</div>
";
}
}
function getCats(){
global $con;
$getCatsQuery = "select * from categories";
$getCatsResult = mysqli_query($con,$getCatsQuery);
while($row = mysqli_fetch_assoc($getCatsResult)){
$cat_id = $row['cat_id'];
$cat_title = $row['cat_title'];
echo "<li><a class='nav-link' href='index.php?cat=$cat_id'>$cat_title</a></li>";
}
}
function getBrands(){
global $con;
$getBrandsQuery = "select * from brands";
$getBrandsResult = mysqli_query($con,$getBrandsQuery);
while($row = mysqli_fetch_assoc($getBrandsResult)){
$brand_id = $row['brand_id'];
$brand_title = $row['brand_title'];
echo "<li><a class='nav-link' href='index.php?brand=$brand_id'>$brand_title</a></li>";
}
}