-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy patharticleOfCategory.php
More file actions
130 lines (99 loc) · 4.78 KB
/
articleOfCategory.php
File metadata and controls
130 lines (99 loc) · 4.78 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
<!-- Include Head -->
<?php include "assest/head.php"; ?>
<?php
$catID = "";
// Get All Categories
$stmt = $conn->prepare("SELECT * FROM `category` ");
$stmt->execute();
$categories = $stmt->fetchAll();
if (isset($_GET["catID"])) {
$catID = $_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 = ? 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 ORDER BY `article_created_time` DESC ");
$stmt->execute();
$articles = $stmt->fetchAll();
}
?>
<!-- Google Fonts -->
<!-- <link href="https://fonts.googleapis.com/css?family=Playfair+Display:700,900" rel="stylesheet"> -->
<link href="https://fonts.googleapis.com/css?family=Nunito+Sans:700%7CNunito:300,600" rel="stylesheet">
<!-- Custom CSS -->
<!-- <link href="css/home.css" rel="stylesheet"> -->
<link href="css/style.css" type="text/css" rel="stylesheet" />
<title>Articles</title>
</head>
<body class="d-flex flex-column min-vh-100">
<!-- Header -->
<?php include "assest/header.php" ?>
<!-- </Header> -->
<!-- Main -->
<main class="main">
<!-- Latest Articles -->
<div class="section jumbotron mb-0 h-100">
<!-- container -->
<div class="container">
<!-- row -->
<div class="row">
<div class="col-md-12">
<div class="section-title">
<h2><?= $catID == "" ? "" : $category['category_name'] ?> Articles</h2>
<ul class="list-inline mt-1 mb-4">
<li class="list-inline-item">
<a href="articleOfCategory.php" class="text-muted">
All
</a>
</li>
<?php foreach ($categories as $category) : ?>
<li class="list-inline-item">
<a href="articleOfCategory.php?catID=<?= $category['category_id'] ?>" class="text-muted">
<?= $category['category_name'] ?>
</a>
</li>
<?php endforeach; ?>
</ul>
</div>
</div>
<?php foreach ($articles as $article) : ?>
<!-- post -->
<div class="col-md-4">
<div class="post">
<a class="post-img" href="single_article.php?id=<?= $article['article_id'] ?>">
<img src="img/article/<?= $article['article_image'] ?>" alt="">
</a>
<di class="post-body">
<div class="post-meta">
<a class="post-category cat-1" href="articleOfCategory.php?catID=<?= $article['category_id'] ?>" style="background-color:<?= $article['category_color'] ?>"><?= $article['category_name'] ?></a>
<span class="post-date">
<?= date_format(date_create($article['article_created_time']), "F d, Y ") ?>
</span>
</div>
<h3 class="post-title"><a href="single_article.php?id=<?= $article['article_id'] ?>"><?= $article['article_title'] ?></a></h3>
</di>
</div>
</div>
<!-- /post -->
<?php endforeach; ?>
<div class="clearfix visible-md visible-lg"></div>
</div>
<!-- /row -->
</div>
<!-- /container -->
</div>
</main><!-- </Main> -->
<!-- Footer -->
<?php include "assest/footer.php" ?>
<!-- </Footer> -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="https://code.jquery.com/jquery-3.4.1.slim.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"></script>
</body>
</html>