/
notifications.php
60 lines (52 loc) · 1.75 KB
/
notifications.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
<?php
error_reporting(0);
include("./inc/header.inc.php");
if($username){
echo '<div style="height:40px; width:100%;"></div>';
}
else{
echo '<div style="height:40px; width:100%;"></div>';
die ("You must be logged in to view this page!");
}
?>
<h2>All Notifications:</h2><hr />
<ul class="notifications">
<?php
$query = mysql_query("SELECT * FROM notifications WHERE user_to = '$username' AND deleted = '0' ")or die(mysql_error());
$rows = mysql_num_rows($query);
if($rows != 0){
while($get = mysql_fetch_array($query)){
$topic = $get['topic'];
$activity = $get['activity'];
$date_added = $get['date_added'];
$added_by = $get['added_by'];
$notification_id = $get['notification_id'];
$users_query = mysql_query("SELECT first_name, last_name FROM users WHERE username='$added_by'");
$full_name = mysql_fetch_assoc($users_query);
$firstname = $full_name['first_name'];
$lastname = $full_name['last_name'];
?>
<li>
<?php
if(@$_POST['clear_' . $notification_id . '']){
$delete_query = mysql_query("DELETE FROM notifications WHERE notification_id = '$notification_id'") or die (mysql_error());
//header("Location: my_messages.php");
echo "<meta http-equiv=\"refresh\" content=\"0; url=notifications.php\">";
}
?>
<form method="POST" action="notifications.php" name="clear_notifications" >
<b style="font-size:16px; font-weight:200;">
<a href="topics.php?topic=<?php echo $added_by; ?>"><?php echo $firstname." ".$lastname." " ;?></a>
<?php echo $activity." "; ?>in
<a href="topics.php?topic=<?php echo $topic; ?>"><?php echo " ".$topic." "; ?></a> on
<?php echo " ".$date_added;?></b>
<input type="submit" name="clear_<?php echo $notification_id; ?>" value="clear" title="clear this notification" >
</form>
</li>
<?php }?>
<?php
}
else
echo "No notifications to display!";
?>
</ul>