-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathblog.php
More file actions
97 lines (81 loc) · 2.34 KB
/
blog.php
File metadata and controls
97 lines (81 loc) · 2.34 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
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<?php
// Database connection
$conn = new mysqli("localhost", "root", "", "Atechnologies");
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// Fetch blogs from the database
$sql = "SELECT * FROM blogs ORDER BY created_at DESC LIMIT 10";
$result = $conn->query($sql);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Responsive Blog Page</title>
<link rel="shortcut icon" href="./image/logo.jpeg" type="image/x-icon">
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
background-color: #f8f8f8;
}
.navbar {
background-color: #333;
color: white;
padding: 10px 20px;
text-align: center;
}
.main {
position: relative;
top: 60px;
padding: 20px;
}
.container {
max-width: 800px;
margin: 20px auto;
background: white;
border-radius: 10px;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
overflow: hidden;
}
.image {
width: 100%;
height: 60vh;
}
.title {
font-size: 24px;
font-weight: bold;
padding: 15px 20px 0;
color: #333;
}
.content {
font-size: 16px;
line-height: 1.6;
padding: 10px 20px;
color: #555;
}
</style>
</head>
<body>
<?php include "nav.php"; ?>
<div class="main">
<?php if ($result->num_rows > 0): ?>
<?php while ($row = $result->fetch_assoc()): ?>
<div class="container">
<img src="<?php echo htmlspecialchars($row['image_url']); ?>" alt="Blog Image" class="image">
<h2 class="title"><?php echo htmlspecialchars($row['title']); ?></h2>
<p class="content"><?php echo nl2br(htmlspecialchars($row['content'])); ?></p>
</div>
<?php endwhile; ?>
<?php else: ?>
<p>No blogs available.</p>
<?php endif; ?>
</div>
<br><br>
<?php include "footer.php"; ?>
</body>
</html>