-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcategory.php
134 lines (113 loc) · 5.86 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
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
<?php
require "assets/db.php";
require "assets/varnames.php";
require 'assets/sharedComponents.php';
$components = new SharedComponents();
if(!isset($_GET["catID"]))
{
header("location: 404.php?err=Error Getting Category");
exit;
}
include 'includes/header.php';
include 'includes/navbar.php';
$catID = "";
// Get All Categories
$stmt = $conn->prepare("SELECT * FROM `category` ");
$stmt->execute();
$categories = $stmt->fetchAll();
if (isset($_GET["catID"])) {
$catID = $components->unprotect($_GET["catID"]);
// Get Category Info
$stmt = $conn->prepare("SELECT * FROM `category` WHERE category_id = ?");
$stmt->execute([$catID]);
$category = $stmt->fetch();
// Get Latest articles
$stmt = $conn->prepare("SELECT * FROM `article` INNER JOIN category ON id_categorie=category_id WHERE id_categorie = ? AND article_status=1 ORDER BY `article_created_time` DESC ");
$stmt->execute([$catID]);
$articles = $stmt->fetchAll();
} else {
$stmt = $conn->prepare("SELECT * FROM `article` INNER JOIN category ON id_categorie=category_id WHERE article_status=1 ORDER BY `article_created_time` DESC ");
$stmt->execute();
$articles = $stmt->fetchAll();
}
$returntitle = $category['category_name'];
?>
<!--section-heading-->
<div class="section-heading " >
<div class="container-fluid">
<div class="section-heading-2">
<div class="row">
<div class="col-lg-12">
<div class="section-heading-2-title ">
<h1> <?= $catID == "" ? "Category cannot be found" : $category['category_name'] ?> </h1>
<p class="links"><a href="index.php">Home <i class="las la-angle-right"></i></a> Category(s)</p>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- category-->
<section class="blog-author mt-30">
<div class="container-fluid">
<div class="">
<!--content-->
<div class="">
<div class="row theiaStickySidebar">
<?php foreach ($articles as $article) : ?>
<!--post1-->
<div class="col-lg-6">
<br>
<div class="post-list post-list-style4 pt-0">
<div class="post-list-image">
<a href="post-single.php?data=<?=substr($article['article_title'],0,30)."..."?>&id=<?= $components->protect($article['article_id']) ?>">
<img src="img/article/<?= $article['article_image'] ?>" alt="">
</a>
</div>
<div class="post-list-content">
<ul class="entry-meta">
<li class="entry-cat">
<a href="category.php?data=<?=substr($article['category_name'],0,30)."..."?>&catID=<?= $components->protect($article['category_id']) ?>" class="category-style-1" style="color:<?= $article['category_color'] ?>">
<?= $article['category_name'] ?>
</a>
</li>
<li class="post-date"> <span class="line"></span><?= date_format(date_create($article['article_created_time']), "F d, Y ") ?></li>
</ul>
<h5 class="entry-title">
<a href="post-single.php?data=<?=substr($article['article_title'],0,30)."..."?>&id=<?= $components->protect($article['article_id']) ?>">
<?= strlen($article['article_title']) > 30 ? substr($article['article_title'],0,30)."..." : $article['article_title']; ?>
</a>
</h5>
<div class="post-btn">
<a href="post-single.php?data=<?=substr($article['article_title'],0,30)."..."?>&id=<?= $components->protect($article['article_id']) ?>" class="btn-read-more">Continue Reading <i class="las la-long-arrow-alt-right"></i></a>
</div>
</div>
</div>
</div>
<?php endforeach; ?>
</div>
<!--pagination-->
<!-- <div class="pagination">
<div class="pagination-area text-left">
<div class="pagination-list">
<ul class="list-inline">
<li><a href="#" ><i class="las la-arrow-left"></i></a></li>
<li><a href="#" class="active">1</a></li>
<li><a href="#">2</a></li>
<li><a href="#">3</a></li>
<li><a href="#">4</a></li>
<li><a href="#" ><i class="las la-arrow-right"></i></a></li>
</ul>
</div>
</div>
</div> -->
<br>
</div>
<!--/-->
</div>
</div>
</section>
<?php
include 'includes/footer.php';
include 'includes/scripts.php';
?>