-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathposts.php
120 lines (95 loc) · 2.43 KB
/
posts.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
<?php
include('include/connection.php');
include('include/header.php');
if (isset($_GET['id']))
{
$id = $_GET['id'];
}
if(isset($id)){
$query ="DELETE FROM posts WHERE id ='$id'";
$delete = mysqli_query($con,$query);
if(isset($delete)){
echo "<div class='alert alert-success'>"."تم الحذف بنجاح"."</div>";
}else{
echo "<div class='alert alert-danger'>"."حدث خطأ ما"."</div>";
}
}
?>
<!-- Start Container -->
<div class="content">
<div class="container-fluid">
<div class="row">
<div class="col-md-2" id="side-area">
<h4>لوحة التحكم</h4>
<ul>
<li><a href="categories.php">
<span class=""> <i class="fas fa-tags"></i> </span>
<span class="">التصنيفات</span>
</a></li>
<!-- المقالات -->
<li data-toggle="collapse" data-target="#menu">
<a href="#">
<span class=""> <i class="far fa-newspaper"></i> </span>
<span class="">المقالات</span>
</a>
</li>
<ul class="collapse" id="menu">
<li>
<a href="new-post.php">
<span><i class="fas fa-edit"></i></span>
<span>مقال جديد</span>
</a>
</li>
<li>
<a href="posts.php">
<span><i class="fas fa-th-large"></i></span>
<span>كل المقالات</span>
</a>
</li>
</ul>
<!-- المقالات -->
<li><a href="index.php" target="_blank">
<span class=""> <i class="fas fa-window-restore"></i> </span>
<span class="">عرض الموقع</span>
</a></li>
<li><a href="logout.php">
<span class=""> <i class="fas fa-sign-out-alt"></i> </span>
<span class="">تسجيل الخروج</span>
</a></li>
</ul>
</div>
<div class="col-md-10" id="main-area">
<!-- Display all posts -->
<table class="table table-ordered">
<tr>
<th>عنوان المقال</th>
<th>كاتب المقال</th>
<th>صورة المقال</th>
<th>تاريخ المقال</th>
<th>حذف المقال</th>
</tr>
<?php
$query = "SELECT * FROM posts ORDER BY id DESC";
$res = mysqli_query($con,$query);
while($row = mysqli_fetch_assoc($res)){
?>
<tr>
<td> <?php echo $row['postTitle']; ?> </td>
<td> <?php echo $row['postAuthor']; ?> </td>
<td> <img src="uploads/<?php echo $row['postImage'];?>" width="100px" height="80px"> </td>
<td> <?php echo $row['postDate']; ?> </td>
<td> <a href="posts.php?id=<?php echo $row['id'] ?>">
<button class="btn-custom">حذف المقال</button> </a> </td>
</tr>
<?php
}
?>
</table>
</div>
</div>
</div>
</div>
<!-- End Container -->
<?php
include('include/footer.php');
?>