-
Notifications
You must be signed in to change notification settings - Fork 0
/
blog.php
200 lines (188 loc) · 5.93 KB
/
blog.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
<?php
ob_start();
include('header.php');
require('database/connection.php');
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style type="text/css">
body {
margin: 0;
background-color: #f0f0f0;
color: #333;
font-family: Arial, sans-serif;
}
.top-bar {
background: #6c8ba3;
color: #fff;
text-align: center;
padding: 20px 0;
box-shadow: 0 4px 2px -2px gray;
}
#topBarTitle {
font-size: 2rem;
margin: 0;
font-weight: bold;
font-family: 'Georgia', serif;
font-style: italic;
color: #fff;
text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.2);
}
.container {
width: 90%;
max-width: 1200px;
margin: 0 auto;
padding: 20px 0;
}
.row {
display: flex;
flex-wrap: wrap;
justify-content: center;
margin: -10px;
}
.col {
flex: 1 1 calc(33.333% - 20px);
margin: 10px;
box-sizing: border-box;
}
.post-container {
background: #fff;
padding: 20px;
border-radius: 8px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
display: flex;
flex-direction: column;
width: 100%;
max-width: 350px;
height: 500px;
transition: transform 0.3s, height 0.3s;
overflow: hidden;
}
.post-container:hover {
transform: translateY(-10px);
}
.post-container img {
width: 100%;
height: 200px;
object-fit: cover;
border-radius: 8px;
margin-bottom: 15px;
}
#displayTitle {
font-weight: bold;
font-size: 1.5rem;
margin-bottom: 10px;
color: #007bff;
text-align: center;
}
.post-details {
font-size: 0.9rem;
color: #666;
margin-bottom: 15px;
text-align: center;
}
.post-content {
position: relative;
overflow: hidden;
}
.full-content {
display: none;
}
.write-post {
text-align: center;
margin: 20px 0;
}
.write-post a {
color: #fff;
background: #007bff;
padding: 10px 25px;
text-decoration: none;
border-radius: 50px;
transition: background 0.3s;
}
.write-post a:hover {
background: #0056b3;
}
@media (max-width: 768px) {
.col {
flex: 1 1 calc(50% - 20px);
}
}
@media (max-width: 480px) {
.col {
flex: 1 1 100%;
}
}
</style>
</head>
<body>
<div class="top-bar">
<span id="topBarTitle"> Traveler's Diary </span>
</div>
<div class="container">
<div class="row">
<?php
if ($con->connect_error)
die("Connection Error" . $con->connect_error);
$sql = "SELECT topic_title, topic_date, name, duration, person, cost, image_filename, topic_para FROM blog_table;";
$stmt = $con->prepare($sql);
$stmt->execute();
$result = $stmt->get_result();
if ($result->num_rows > 0) {
while ($row = $result->fetch_assoc()) {
$para_snippet = htmlspecialchars(implode(' ', array_slice(explode(' ', $row["topic_para"]), 0, 20)) . '...', ENT_QUOTES, 'UTF-8');
echo "<div class='col'>";
echo "<div class='post-container' id='post-container-" . htmlspecialchars($row["topic_title"], ENT_QUOTES, 'UTF-8') . "'>";
echo "<span id='displayTitle'>Place : " . htmlspecialchars($row["topic_title"], ENT_QUOTES, 'UTF-8') . "</span>";
echo "<div class='post-details'>";
echo "<span id='displayDate'>Travel Date: " . htmlspecialchars($row["topic_date"], ENT_QUOTES, 'UTF-8') . "</span><br>";
echo "<span id='name'>Posted by: " . htmlspecialchars($row["name"], ENT_QUOTES, 'UTF-8') . "</span><br>";
echo "<span id='duration'>Duration: " . htmlspecialchars($row["duration"], ENT_QUOTES, 'UTF-8') . " days</span><br>";
echo "<span id='person'>Total Tourist: " . htmlspecialchars($row["person"], ENT_QUOTES, 'UTF-8') . " Person</span><br>";
echo "<span id='cost'>Total Cost: " . htmlspecialchars($row["cost"], ENT_QUOTES, 'UTF-8') . " Tk</span>";
echo "</div>";
echo "<img src='./assets/blog/images/" . htmlspecialchars($row["image_filename"], ENT_QUOTES, 'UTF-8') . "' alt='Blog Image'>";
echo "<div class='post-content' id='post-content-" . htmlspecialchars($row["topic_title"], ENT_QUOTES, 'UTF-8') . "' onclick='seeMore(\"" . htmlspecialchars($row["topic_title"], ENT_QUOTES, 'UTF-8') . "\")'>";
echo "<p id='displayPara-" . htmlspecialchars($row["topic_title"], ENT_QUOTES, 'UTF-8') . "'>" . $para_snippet . "<span class='see-more'> See More</span></p>";
echo "<p id='fullPara-" . htmlspecialchars($row["topic_title"], ENT_QUOTES, 'UTF-8') . "' class='full-content'>" . htmlspecialchars($row["topic_para"], ENT_QUOTES, 'UTF-8') . "</p>";
echo "</div>";
echo "</div>";
echo "</div>";
}
} else {
echo "<center><span>No Blog Posts Found</span></center>";
}
$stmt->close();
$con->close();
?>
</div>
</div>
<div class="write-post">
<a href='cBlog.php'>Write a New Post</a>
</div>
<script>
function seeMore(title) {
var postContainer = document.getElementById('post-container-' + title);
var snippet = document.getElementById('displayPara-' + title);
var fullContent = document.getElementById('fullPara-' + title);
var seeMoreText = snippet.querySelector('.see-more');
if (fullContent.style.display === 'none' || fullContent.style.display === '') {
snippet.style.display = 'none';
fullContent.style.display = 'block';
postContainer.style.height = 'auto';
} else {
snippet.style.display = 'block';
fullContent.style.display = 'none';
postContainer.style.height = '500px';
seeMoreText.style.display = 'inline';
}
}
</script>
</body>
</html>
<?php
include('footer.php');
?>