-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.php
More file actions
37 lines (32 loc) · 956 Bytes
/
main.php
File metadata and controls
37 lines (32 loc) · 956 Bytes
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
<?php
require('conf/db.php');
require('conf/conf.php');
$query = 'SELECT * FROM post ORDER BY created_at DESC';
$result =mysqli_query($conn,$query);
$posts =mysqli_fetch_all($result,MYSQLI_ASSOC);
mysqli_free_result($result);
mysqli_close($conn);
?>
<!DOCTYPE html>
<html>
<head>
<title>BLOG</title>
<link rel="stylesheet" type="text/css" href="conf/bootstrap.min.css">
</head>
<body>
<?php include('navbar.php'); ?>
<div class='container' class="d-flex w-100 justify-content-between">
<h1>Posts</h1>
<?php foreach($posts as $post): ?>
<div class='well'>
<h3 ><?php echo $post['title']; ?></h3>
<small>Created on <?php echo $post['created_at']; ?>
<?php echo $post['author']; ?>
</small>
<p><<?php echo $post ['body']; ?></p>
<a class='btn btn-default' href="<?php echo ROOT_URL;?>post.php?id=<?php echo $post['id'];?>">Read More</a>
</div>
<?php endforeach; ?>
</div>
</body>
</html>