-
Notifications
You must be signed in to change notification settings - Fork 0
/
blog_list.php
70 lines (53 loc) · 1.69 KB
/
blog_list.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
<?php
include "inc/header.php";
include "classes/WinMat.php";
include "classes/Post.php";
$db = new Database();
$format = new Format();
$username = $_SESSION['ins_name'];
$userlogin = $_SESSION['ins_login'];
//delete blog
if($userlogin){
if(isset($_REQUEST['del'])){
$id = $_REQUEST['del'];
$del = $db->delete("DELETE FROM blog_post WHERE blog_id = '$id' AND blog_author= '$username' AND user_email = '$userlogin' ");
if($del){
Format::jumpTo("blog_list.php", "deleted");
}else{
Format::jumpTo("blog_list.php", "not deleted :(");
}
}
}else{
Format::jumpTo("blog_list.php", "Your not eligible :(");
}
//end delete
?>
<table class="table table-responsive table-dark table-hover">
<tr>
<th>SL</th>
<th>Title</th>
<th>Description</th>
<th>Status</th>
<th>Created at</th>
<th>Action</th>
</tr>
<?php
$getBlog = $db->select("SELECT * FROM blog_post WHERE blog_author= '$username' AND user_email = '$userlogin' ORDER BY id DESC ");
?>
<?php if($getBlog): ?>
<?php $i = 0; ?>
<?php while($row = $getBlog->fetch_assoc()): ?>
<?php $i++; ?>
<tr>
<td><?php echo $i; ?></td>
<td><?php echo $row['blog_title']; ?></td>
<td><?php echo $format->Stext(Format::textShorten($row['blog_description'])); ?></td>
<td><?php echo $row['blog_status']; ?></td>
<td><?php echo $row['created_at']; ?></td>
<td><a href="blog_edit.php?edit=<?php echo $row['blog_id']; ?>">Edit</a> | <a href="?del=<?php echo $row['blog_id']; ?>">Delete</a></td>
</tr>
<?php endwhile ?>
<?php else: ?>
<?php endif ?>
</table>
<?php include "inc/footer.php"; ?>