-
Notifications
You must be signed in to change notification settings - Fork 0
/
post_manage.php
270 lines (227 loc) · 10.1 KB
/
post_manage.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
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
<?php
$conn = mysqli_connect("localhost", "root", "", "local_theatre2");
if (!$conn) {
die(mysqli_connect_error());
}
$result = mysqli_query($conn, "SELECT * FROM blog");
$c_time = date('Y-m-d');
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<!-- css -->
<link rel="stylesheet" href="css/style.css" />
<link rel="stylesheet" type="text/css" href="fontawesome/css/all.css">
</head>
<body>
<!-- header section -->
<?php include "header.php" ?>
<!-- Main Section -->
<section id="admin_dash">
<div class="header">
<h1>Admin Dashboard</h1>
</div>
<div class="row">
<div class="sidebar">
<ul>
<li><a href="admin_dashboard.php" class="sidebar-link">Dashboard</a></li>
<li><a href="add_article.php" class="sidebar-link">Add Article</a></li>
<li><a href="user_manage.php" class="sidebar-link">Users Manage</a></li>
<li><a href="post_manage.php" class="sidebar-link">Post Manage</a></li>
<li><a href="#" class="sidebar-link">Settings</a></li>
</ul>
</div>
<div class="main">
<h2>Dashboard</h2>
<p>Welcome to the admin dashboard</p>
<div class="cards reveal">
<?php
$result = mysqli_query($conn, "SELECT * FROM blog ORDER BY b_id DESC");
if (mysqli_num_rows($result) > 0) {
while ($row = mysqli_fetch_assoc($result)) {
?>
<div class="card carousel_block">
<h2>
<?php echo $row['b_title'] ?>
</h2>
<h5>
<?php echo $row['b_category'] ?>
</h5>
<div class="fakeimg">
<a href="article_detail.php?b_id=<?php echo $row['b_id']; ?>">
<img src="<?php echo $row['b_image'] ?>" alt="">
</a>
</div>
<h4>Description</h4>
<p>
<?php echo $row['b_desc'] ?>
</p>
<hr class="dotted-line">
<div class="post_meta">
<span class="cat">Posted by <a href="#">Admin</a></span> |
<span class="cat">Date:
<?php echo $c_time; ?>
</span> |
<a href="article_detail.php?b_id=<?php echo $row['b_id']; ?>">
<a href="">Comments</a>
</a>
</div>
<div class="card-buttons">
<a href="add_article.php?edit=<?php echo $row['b_id']; ?>" class="edit-button"><i
class="fa-solid fa-pen-to-square"></i></a>
<button class="delete-button" data-postid="<?php echo $row['b_id']; ?>"><i
class="fa-solid fa-trash"></i></button>
</div>
</div>
<?php
}
}
?>
<div class="pagination">
<a href="#admin_dash" class="prev">Previous</a>
<a href="#admin_dash" class="page active">1</a>
<a href="#admin_dash" class="page">2</a>
<a href="#admin_dash" class="page">3</a>
<a href="#admin_dash" class="next">Next</a>
</div>
</div>
</div>
</div>
</section>
<!-- footer section -->
<?php include "footer.php" ?>
<script src="js/delete_post.js"></script>
<script>
const links = document.querySelectorAll('.sidebar a');
links.forEach(link => {
link.addEventListener('click', () => {
links.forEach(otherLink => otherLink.classList.remove('active'));
link.classList.add('active');
});
});
const currentUrl = window.location.href;
const sidebarLinks = document.querySelectorAll('.sidebar-link');
sidebarLinks.forEach(sidebarLink => {
if (sidebarLink.href === currentUrl) {
sidebarLink.classList.add('active');
}
});
const revealItems = document.querySelectorAll('.reveal_item');
let lastScrollTop = 0;
function revealItem() {
const currentScrollTop = window.pageYOffset || document.documentElement.scrollTop;
revealItems.forEach(item => {
const top = item.getBoundingClientRect().top;
const isRevealed = item.classList.contains('reveal_item--visible');
if (top + 30 < window.innerHeight && top > 0) {
if (!isRevealed || currentScrollTop < lastScrollTop) {
item.classList.add('reveal_item--visible');
}
} else {
if (isRevealed) {
item.classList.remove('reveal_item--visible');
}
}
});
lastScrollTop = currentScrollTop;
}
window.addEventListener('scroll', revealItem);
const cards = document.querySelectorAll('.card');
const pagination = document.querySelector('.pagination');
const prev = pagination.querySelector('.prev');
const pages = pagination.querySelectorAll('.page');
const next = pagination.querySelector('.next');
const cardsPerPage = 9;
const totalPages = Math.ceil(cards.length / cardsPerPage);
let current = 0;
function showPage(page) {
const start = page * cardsPerPage;
const end = start + cardsPerPage;
let anyCardsDisplayed = false;
cards.forEach((card, index) => {
if (index >= start && index < end) {
card.style.display = 'block';
anyCardsDisplayed = true;
} else {
card.style.display = 'none';
}
});
if (anyCardsDisplayed) {
pagination.style.position = 'static';
} else {
// pagination.style.position = 'absolute';
pagination.style.bottom = '15px';
// pagination.style.left = '50%';
// pagination.style.transform = 'translateX(-50%)';
// pagination.style.display = 'flex';
// pagination.style.justify-content = 'center';
// pagination.style.align-items = 'center';
// pagination.style.margin-top = '15px';
}
pages[current].classList.remove('active');
pages[page].classList.add('active');
current = page;
}
function showNext() {
if (current < totalPages - 1) {
showPage(current + 1);
}
}
function showPrev() {
if (current > 0) {
showPage(current - 1);
}
}
// Initially display only the first page of cards
showPage(0);
prev.addEventListener('click', showPrev);
next.addEventListener('click', showNext);
pages.forEach((page, index) => {
page.addEventListener('click', () => {
showPage(index);
});
});
// // Select the leftcolumn div
// const leftcolumn = document.getElementById('leftcolumn');
// // Listen for scroll events
// window.addEventListener('scroll', () => {
// // Calculate the position of the leftcolumn div relative to the viewport
// const leftcolumnPosition = leftcolumn.getBoundingClientRect().top;
// // If the leftcolumn div is in the viewport, fade it in
// if (leftcolumnPosition < window.innerHeight) {
// leftcolumn.style.left = '0';
// leftcolumn.style.opacity = 1;
// }
// });
const fadeElems = document.querySelectorAll('.fade-in');
function checkFade() {
fadeElems.forEach(fadeElem => {
const elemTop = fadeElem.getBoundingClientRect().top;
const elemBottom = fadeElem.getBoundingClientRect().bottom;
const windowHeight = window.innerHeight;
if (elemTop < windowHeight && elemBottom >= 0) {
fadeElem.classList.add('visible');
} else {
fadeElem.classList.remove('visible');
}
});
}
window.addEventListener('load', checkFade);
window.addEventListener('scroll', checkFade);
window.addEventListener('resize', checkFade);
$(document).ready(function () {
$('.reveal').css('opacity', 0);
$('.reveal').waypoint(function () {
$('.reveal').addClass('fadeInUp');
}, { offset: 'bottom-in-view' });
});
// $(document).ready(function() {
// $('.reveal').hide().fadeIn(1000);
// });
</script>
</body>
</html>