-
Notifications
You must be signed in to change notification settings - Fork 0
/
admin_comment.php
170 lines (143 loc) · 5.67 KB
/
admin_comment.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
<?php include("includes/connection.php");
include("admin.php"); ?>
<?php include("includes/connection.php");
if(isset($_POST['submit'])){
$id = $_POST['deleteuser'];
$delete ="DELETE FROM comment WHERE comment_id = '$id' ";
if (mysqli_query($conn, $delete)) {
echo "Record updated successfully";
} else {
echo "Error updating record: " . mysqli_error($conn);
}
}
?>
<html>
<head>
<title>Comment</title>
<style type="text/css">
.bodymargin{
margin:80px 0px 10px 40px;
}
.head-table {
font-size: 40px;
font-family: "Yu Gothic UI Light";
color: #2a8048;
position: absolute;
top: 176px;
left: 45px;
}
.head-user{
font-variant: small-caps;
font-size: 50px;
font-family: "Yu Gothic UI Light";
color: rgb( 00, 00, 00 );
position: absolute;
top: 159px;
left: 196px;
z-index: 19;
}
.hr{
position: absolute;
border: 1px solid #2a8048;
top: 235px;
margin-left: -26px;
width: 1150px;
left: 73px;
}
.deletebar{
border-radius: 8px;
border: 1px solid none;
background-color: #fff;
position: absolute;
top: 6px;
width:150px;
height: 30px;
}
.delbutton{
text-decoration: none;
cursor: pointer;
border-radius: 8px;
padding: 5px 8px 5px 8px;
font-family: "Yu Gothic UI Light";
color: white;
font-size: 13px;
background-color: #FF0017;
position: relative;
top:100px;
left:60px;
}
/* .rowdesign:nth-child(odd){
background-color: #f2f2f2;
top:100px;
}*/
.table-head{
font-weight: bold;
position:relative;
top:100px;
}
.table-head .table-data{
padding:10px;
text-align: center;
border-bottom: 1px solid none;
position:relative;
top:100px;
font-family: "Yu Gothic UI Light";
}
/* .table-head:hover{
background-color: #f5f5f5;
}*/
</style>
</head>
<body class="bodymargin">
<script>
function YNconfirm() {
if (window.confirm('Are you sure you want to delete this Comment?'))
{
return true;
}
else
return false;
};
</script>
<form action ="admin_comment.php" method="POST">
<?php
$result1 = mysqli_query($conn,"SELECT * FROM comment");
if (!$result1) {
die("Query to show fields from table failed");
}
if(mysqli_num_rows($result1) <=0){
echo '<h1 align="Center"><br><br><br><br><br><br><br>No Comments Available </h1>';
}
else{
$fields_num1 = mysqli_num_fields($result1);
echo '<p><h1 class="head-table" >TABLE: </h1>
<h1 class="head-user" >Comment</h1><br> <hr class="hr" style="border-bottom: 2px solid #2a8048;">
</p>';
echo '<table style="position: absolute; top:180px;left:70px;border-collapse: collapse; width: 1050px;"><tr class="table-head">';
// printing table headers
for($i=0; $i<$fields_num1; $i++){
$field1 = mysqli_fetch_field($result1);
echo '<td class="table-data" style="background-color:#308f3f; color:white;" >'.$field1->name.'</td>';
}
echo '<td class="table-data" style="background-color:#308f3f; color:white;"> ACTION </td>';
echo "</tr>\n";
// printing table rows
//
while($row1 = mysqli_fetch_row($result1)){
echo '<tr class="rowdesign table-head">';
// $row is array... foreach( .. ) puts every element
// of $row to $cell variable
echo '<td class="table-data">'.$row1[0].'</td>';
echo '<td class="table-data">'.$row1[1].'</td>';
echo '<td class="table-data">'.$row1[2].'</td>';
echo '<td class="table-data">'.$row1[3].'</td>';
echo '<td class="table-data">'.$row1[4].'</td>';
echo '<td> <a class="delbutton" href="delete_comment.php?id='.$row1[0].'"onclick="return(YNconfirm());"> Delete</a></td>';
echo "</tr>\n";
}
mysqli_free_result($result1);
}
?>
</form>
</body>
</html>