-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.php
82 lines (46 loc) · 1.98 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Blog Using PHP And MySQL</title>
<link rel="stylesheet" href="styles/style.css">
</head>
<body>
<div class="top-bar">
<span id="topBarTitle">Blog | All Posts</span>
</div>
<br>
<div class="all-posts-container">
<?php
$servername = "localhost";
$username = "root";
$password = "";
$database = "blog_db";
$conn = new mysqli($servername, $username, $password, $database);
if($conn->connect_error) die("Connection Error" . $conn->connect_error);
$sql = "select topic_title, topic_date, image_filename, topic_para from blog_table;";
$result = $conn->query($sql);
if($result->num_rows > 0)
{
while($row = $result->fetch_assoc())
{
echo "<div style='padding: 25px 25px;' class='post-container'>";
echo "<span id='displayTitle'>" . $row["topic_title"] . "</span><br>";
echo "<span id='displayDate'>" . $row["topic_date"] . "</span><br><br>";
echo "<img style='width: 100%; height: auto' id='displayImage' src='images/" . $row["image_filename"] . "'><br>";
echo "<p style='overflow: hidden; display: -webkit-box; -webkit-line-clamp: 10; line-clamp: 10; -webkit-box-orient: vertical;' id='displayPara'>" . $row["topic_para"] . "</p><br>";
echo "</div>";
}
}
else
{
echo "<center><span>No Blog Posts Found</span></center>";
// echo "<center><a style='color: dodgerblue;' href='index.html'>Write a New Post</a></center>";
}
$conn->close();
?>
</div>
<?php echo "<br><center><a style='color: dodgerblue; text-decoration: none; background: dodgerblue; padding: 5px 25px; color: #fff; border-radius: 50px;' href='index.html'>Write a New Post</a></center><br>"; ?>
</body>
</html>