-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcategory.php
43 lines (36 loc) · 1.3 KB
/
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
<?php
require_once("core/init.php");
include("includes/head.php");
include("includes/navigation.php");
include("includes/headerpartial.php");
include("includes/leftbar.php");
if(isset($_GET['cat'])){
$cat_id = sanitize($_GET['cat']);
} else {
$cat_id = '';
}
$sql = "SELECT * FROM products WHERE categories = '$cat_id'";
//use the $db object and call the query method with the query as argument
$productQ = $db->query($sql);
$category = get_category($cat_id);
?>
<!--Main Content-->
<div class="col-md-8">
<div class="row">
<h2 class="text-center"><?=$category['parent'].' '.$category['child'];?></h2>
<?php while($product = mysqli_fetch_assoc($productQ)) : ?>
<div class="col-md-3 text-center">
<h4><?= $product['title']; ?></h4>
<?php $photos = explode(',',$product['image']); ?>
<img src="<?= $photos[0]; ?>" alt="<?= $product['title']; ?>" class="img-thumb"/>
<p class="list-price text-danger">List Price: <s>£<?= $product['list_price']; ?></s></p>
<p class="price">Our Price: £<?= $product['price']; ?></p>
<button type="button" class="btn btn-sm btn-success" onclick="detailsmodal(<?=$product['id'];?>)">Details</button>
</div>
<?php endwhile; ?>
</div>
</div>
<?php
include("includes/rightbar.php");
include("includes/footer.php");
?>