-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.php
60 lines (55 loc) · 1.74 KB
/
index.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
<?php
require('config/config.php');
#checking if connection is successful or not.
require('config/db.php');
// require('inc/navbar.php');
#create query
$query = 'SELECT * FROM post ORDER bY created_at DESC';
#get result
$result = mysqli_query($conn,$query);
#fetch data
$posts = mysqli_fetch_all($result, MYSQLI_ASSOC);
// echo "<hr>";
// foreach($posts as $post){
// foreach($post as $p){
// echo "<br> $p";
// }echo "<hr>";
// }
#free result
mysqli_free_result($result);
#close connection
mysqli_close($conn);
?>
<!DOCTYPE html>
<html>
<head>
<?php ?>
<title>Tugas 4</title>
<?php require('inc/header.php');?>
</head>
<body>
<?php require('inc/navbar.php');?>
<div class="container-fluid " style="background-color:burlywood; padding:20px">
<h1 class="text-center h"><b>Tugas 4</b></h1>
<div class="container">
<?php foreach($posts as $post):?>
<hr>
<div class="jumbotron bg-dark" style="color:ghostwhite">
<h3>|<?php echo $post['title']; ?></h3>
<small>
Created On
<?php echo $post['created_at'];?>
<br>by
<span style="color:yellow"> <?php echo $post['author'];?></span>
</small><hr>
<i><p style="padding-left:5%;padding-right:10%; font-size:2vw">"<?php echo $post['body'];?>"</p></i> <br>
<div class="text-right">
<a class="btn btn-success" href="<?php echo ROOT_URL; ?>post.php?id=<?php echo $post['id']; ?>">read more</a>
</div>
</div>
<?php endforeach; ?>
</div>
</div>
<?php require('inc/footer.php');?>
</body>
</html>