-
Notifications
You must be signed in to change notification settings - Fork 0
/
category.php
84 lines (70 loc) · 2.55 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
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
<?php include 'includes/session.php'; ?>
<?php
$slug = $_GET['category'];
$conn = $pdo->open();
try{
$stmt = $conn->prepare("SELECT * FROM category WHERE cat_slug = :slug");
$stmt->execute(['slug' => $slug]);
$cat = $stmt->fetch();
$catid = $cat['id'];
}
catch(PDOException $e){
echo "There is some problem in connection: " . $e->getMessage();
}
$pdo->close();
?>
<?php include 'includes/header.php'; ?>
<body class="hold-transition skin-blue layout-top-nav">
<div class="wrapper">
<?php include 'includes/navbar.php'; ?>
<div class="content-wrapper">
<div class="container">
<!-- Main content -->
<section class="content">
<div class="row">
<div class="col-sm-12">
<center><big><h1 class="page-header"><b><u>CATEGORY NAME: <?php echo $cat['name']; ?></u></b></h1></big></center>
<?php
$conn = $pdo->open();
try{
$inc = 4;
$stmt = $conn->prepare("SELECT * FROM products WHERE category_id = :catid");
$stmt->execute(['catid' => $catid]);
foreach ($stmt as $row) {
$image = (!empty($row['photo'])) ? 'images/'.$row['photo'] : 'images/noimage.jpg';
$inc = ($inc == 3) ? 1 : $inc + 1;
if($inc == 1) echo "<div class='row'>";
echo "
<div class='col-sm-4' style='background:#ABEBC6'></br>
<div class='box box-solid' style='background:#CCD1D1'>
<div class='box-body prod-body'>
<p><b>
PRICE: ৳ ".number_format($row['price'], 2)."<span></span>
<span class='pull-right'>FOR: 1 HOUR (Min.)<span></span></span></b>
</p>
<img src='".$image."' width='100%' height='200px' class='thumbnail'>
<center><h3><b><u><a href='product.php?product=".$row['slug']."'>".$row['name']."</a></u></b></h3></center>
</div>
</div>
</div>
";
if($inc == 3) echo "</div>";
}
if($inc == 1) echo "<div class='col-sm-4'></div><div class='col-sm-4'></div></div>";
if($inc == 2) echo "<div class='col-sm-4'></div></div>";
}
catch(PDOException $e){
echo "There Is Connection Problem: " . $e->getMessage();
}
$pdo->close();
?>
</div>
</div>
</section>
</div>
</div>
<?php include 'includes/footer.php'; ?>
</div>
<?php include 'includes/scripts.php'; ?>
</body>
</html>