-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpost.php
More file actions
48 lines (41 loc) · 1.43 KB
/
post.php
File metadata and controls
48 lines (41 loc) · 1.43 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
<?php include 'inc/header.php' ?>
<?php
$postid = mysqli_real_escape_string($db->link, $_GET['id']);
if (!isset($postid) || $postid == NULL) {
header("Location:404.php");
}else{
$id = $postid;
}
?>
<div class="contentsection contemplete clear">
<div class="maincontent clear">
<div class="about">
<?php
$query = "SELECT * FROM table_post WHERE id=$id";
$post = $db->select($query);
if ($post) {
while($result = $post->fetch_assoc()){
?>
<h2><?php echo $result['title']; ?></h2>
<h4><?php echo $format->formatDate($result['date']); ?> By <a href="#"><?php echo $result['author']; ?></a></h4>
<img src="admin/<?php echo $result['image']; ?>" alt="post image"/>
<?php echo $result['body']; ?>
<div class="relatedpost clear">
<h2>Related articles</h2>
<?php
$catid = $result['cat'];
$queryrelated = "SELECT * FROM table_post WHERE cat='$catid' ORDER BY rand() LIMIT 6";
$relatedpost = $db->select($queryrelated);
if ($relatedpost) {
while($relatedresult = $relatedpost->fetch_assoc()){
?>
<a href="post.php?id=<?php echo $relatedresult['id']; ?>">
<img src="admin/upload/<?php echo $relatedresult['image']; ?>" alt="post image"/>
</a>
<?php } } else{ echo "No related post available !!!!";}?>
</div>
<?php } } else { header("Location:404.php"); }?>
</div>
</div>
<?php include 'inc/sidebar.php'; ?>
<?php include 'inc/footer.php'; ?>