-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindexboard.php
More file actions
179 lines (158 loc) · 7.85 KB
/
Copy pathindexboard.php
File metadata and controls
179 lines (158 loc) · 7.85 KB
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
<?php
include( 'dbcon.php');
$query = mysqli_query($con, "SELECT * FROM posts");
session_start(); //error_reporting(0);
?>
<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<title>Digital Notice Board</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="stylesheet" href="css/customsytyle.css">
<link rel="stylesheet" href="css/bootstrap-theme.min.css">
<link rel="stylesheet" href="css/sticky-footer.css" />
<link rel="stylesheet" href="css/Animate.css" type="text/css" />
<script src="js/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<style>
.left-scroll{
padding:5px;
height: 800px;
width: 50%;
float:left;
}
.right-scroll{
padding:5px;
float:right;
width:50%;
height:800px;
}
</style>
</head>
<body>
<nav class="navbar navbar-inverse navbar-static-top">
<div class="container">
<div class="navbar-header">
<a href="index.php" class="navbar-brand">Digital Notice Board</a>
</div>
</div>
<?php
if (!isset($_SESSION['username_current'])) {
echo "<script> $('#loginprocess').hide(); </script>";
}
?>
</nav>
<div class="left-scroll" >
<marquee direction="up" height="800px">
<div class="well-cust">
<?php
if (mysqli_num_rows($query) == 0) {
echo '<div class="container"><p>Oops!! Seems like there aren\'t any posts here </p></div>';
}
while ($row = mysqli_fetch_array($query)) {
?>
<div class="panel panel-info">
<div class="panel-heading">
<h2 class="panel-title"><?php echo $row['heading']; ?></h2>
<cite> -Posted by <?php echo $row['owner']; ?> on <?php echo $row['date']; ?></cite>
</div>
<div class="panel-body">
<blockquote>
<?php echo $row['content']; ?>
</blockquote>
</div>
<?php if (isset($_SESSION['username_current']) && ($_SESSION['fullname'] == $row['owner'])) { ?>
<div class="panel-footer">
<?php
//Logic for deleting
if (isset($_POST['delete_id'])) {
$del_id = $_POST['delete_id'];
$query_delete = "DELETE FROM posts WHERE slno='$del_id'";
$result = mysqli_query($con, $query_delete) or die("Error executing delete query");
if (mysqli_affected_rows($con) == 1) {
echo "<script>window.location.href='studentwall.php'</script>";
} else {
echo 'Error';
}
}
//logic for editing the post
if (isset($_POST['edit_id'])) {
$del_id = $_POST['edit_id'];
$content_update = $_POST['editMessage'];
$query_delete = "UPDATE posts set content='$content_update' WHERE slno='$del_id'";
$result = mysqli_query($con, $query_delete) or die("Error executing delete query");
if (mysqli_affected_rows($con) == 1) {
echo "<script>window.location.href='studentwall.php'</script>";
} else {
echo 'Error';
}
}
?>
</div>
<?php } ?>
</div>
<?php } ?>
</div>
</marquee>
</div>
<div class="right-scroll">
<div class="well-cust">
<?php
$query_latest = "SELECT * FROM posts ORDER BY slno DESC LIMIT 5 ";
$result = mysqli_query($con, $query_latest);
if (mysqli_num_rows($result) == 0) {
echo '<div class="container"><p>Oops!! Seems like there aren\'t any posts here </p></div>';
}
while ($row = mysqli_fetch_array($result)) {
?>
<div class="panel panel-info">
<div class="panel-heading">
<h2 class="panel-title"><?php echo $row['heading']; ?></h2>
<cite> -Posted by <?php echo $row['owner']; ?> on <?php echo $row['date']; ?></cite>
</div>
<div class="panel-body">
<blockquote>
<?php echo $row['content']; ?>
</blockquote>
</div>
<?php if (isset($_SESSION['username_current']) && ($_SESSION['fullname'] == $row['owner'])) { ?>
<div class="panel-footer">
<?php
//Logic for deleting
if (isset($_POST['delete_id'])) {
$del_id = $_POST['delete_id'];
$query_delete = "DELETE FROM posts WHERE slno='$del_id'";
$result = mysqli_query($con, $query_delete) or die("Error executing delete query");
if (mysqli_affected_rows($con) == 1) {
echo "<script>window.location.href='studentwall.php'</script>";
} else {
echo 'Error';
}
}
//logic for editing the post
if (isset($_POST['edit_id'])) {
$del_id = $_POST['edit_id'];
$content_update = $_POST['editMessage'];
$query_delete = "UPDATE posts set content='$content_update' WHERE slno='$del_id'";
$result = mysqli_query($con, $query_delete) or die("Error executing delete query");
if (mysqli_affected_rows($con) == 1) {
echo "<script>window.location.href='studentwall.php'</script>";
} else {
echo 'Error';
}
}
?>
</div>
<?php } ?>
</div>
<?php
}
mysqli_close($con);
?>
</div>
</div>
</body>
</html>