-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcategory.php
105 lines (101 loc) · 4.52 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
<?php
include('public/header.php');
include('classes/posts-contr.class.php');
if(isset($_GET['category'])){
$posts = new PostsContr();
?>
<!-- Start Content -->
<div class="content">
<div class="container">
<div class="row">
<div class="col-md-9">
<?php
$cat = $_GET['category'];
$result = $posts->displayPostsforCategory($cat);
if($result->rowCount() != 0){
while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
?>
<div class="post">
<div class="post-image">
<a href="post.php?id=<?php echo $row['id']; ?>"><img src="uploads/<?php echo $row['postImage']; ?>"></a>
</div>
<div class="post-title">
<h4><a href="post.php?id=<?php echo $row['id']; ?>"><?php echo $row['postTitle']; ?></a></h4>
</div>
<div class="post-details">
<p class="post-info">
<span><i class="fas fa-user"></i><?php echo $row['postAuthor']; ?></span>
<span><i class="far fa-calendar-alt"></i><?php echo $row['postDate']; ?></span>
<span><i class="fas fa-tags"></i><?php echo $row['postCat']; ?></span>
</p>
<p class="postContent">
<?php
if(strlen($row['postContent']) > 150){
$row['postContent'] = substr($row['postContent'], 0, 300) . "...";
}
echo $row['postContent'];
?>
</p>
<a href="post.php?id=<?php echo $row['id']; ?>"><button class="btn btn-custom">إقرأ المزيد</button></a>
</div>
</div>
<?php
}
}
else{
?>
<div class = 'alert alert-danger'>للاسف لايتوفر في الوقت الحالي منشورات من تصنيف: <?php echo $cat?></div>
<?php
}
?>
</div>
<div class="col-md-3">
<!-- Catagories -->
<div class="categories">
<h4>التصنيفات</h4>
<ul>
<?php
$result = $posts->displayCategorieS();
while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
?>
<li>
<a href="category.php?category=<?php echo $row['categoryName']; ?>">
<span><i class="fas fa-tags"></i></span>
<span><?php echo $row['categoryName']; ?></span>
</a>
</li>
<?php
}
?>
</ul>
</div>
<!-- End Categories -->
<!-- Start Latest Posts -->
<div class="last-posts">
<h4>أحدث المنشورات</h4>
<ul>
<?php
$result2 = $posts->displayLastsPosts();
while ($row = $result2->fetch(PDO::FETCH_ASSOC)) {
?>
<li>
<a href="post.php?id=<?php echo $row['id']; ?>">
<span class="span-image"><img src="uploads/<?php echo $row['postImage']; ?>" alt="image1"></span>
<span><?php echo $row['postTitle']; ?></span>
</a>
</li>
<?php
}
?>
</ul>
</div>
<!-- End Latest Posts -->
</div>
</div>
</div>
</div>
<!-- End Content -->
<?php
include('public/footer.php');
}
?>