-
Notifications
You must be signed in to change notification settings - Fork 13
/
news.php
61 lines (45 loc) · 1.55 KB
/
news.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
<?php
include "header.php";
include "navbar.php";
include "connect.php";
?>
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="news_style.css">
</head>
<body>
<div class="flex-container">
<?php
$sql0 = "SELECT id, title, created FROM news ORDER BY created DESC";
$result = $conn->query($sql0);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
$id = $row["id"];
$sql1 = "SELECT body FROM news_body WHERE id=$id";
$result1 = $conn->query($sql1); ?>
<div class="flex-item">
<div class="flex-container-title">
<h1 id="title"><?php echo $row["title"] . "<br>"; ?></h1>
</div>
<div class="flex-container-title">
<p id="date"><?php echo "Date : " .
date("d/m/Y", strtotime($row["created"])); ?></p>
</div>
<div class="flex-container-body">
<p id="news_body">
<?php while($row1 = $result1->fetch_assoc()) {
echo $row1["body"]; } ?></p>
</div>
</div>
<?php }
} else {
echo "No news available ! Please post some.";
}
$conn->close();
?>
</div>
</body>
</html>