-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfetch.php
104 lines (101 loc) · 2.74 KB
/
fetch.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
<?php
//fetch.php;
session_start();
if(isset($_POST["view"]))
{
include("db.php");
$s=$_SESSION['rollno'];
$l=$_SESSION['labid'];
if($_SESSION['type']==0){
$s=$_SESSION['rollno'];
$query = "SELECT * FROM comments WHERE comment_status=0 AND Id='$s' ORDER BY comment_id DESC ";
}
if($_SESSION['type']==1){
$l=$_SESSION['labid'];
$query = "SELECT * FROM comment_sta WHERE comment_status=0 AND labid='$l' ORDER BY comment_id DESC";
}
if($_SESSION['type']==2){
$l=$_SESSION['labid'];
$query = "SELECT * FROM comment_fac WHERE comment_status=0 AND labid='$l' ORDER BY comment_id DESC ";
}
$result = mysqli_query($con, $query);
$output = '';
if(mysqli_num_rows($result) > 0)
{
while($row = mysqli_fetch_array($result))
{
$output .= '
<li>
<a href="#">
<strong>'.$row["comment_subject"].'</strong><br />
<small><em>'.$row["comment_text"].'</em></small>
</a>
</li>
<li class="divider"></li>
';
}
}
else
{
if($_SESSION['type']==0){
$s=$_SESSION['rollno'];
$query = "SELECT * FROM comments WHERE Id='$s' ORDER BY comment_id DESC LIMIT 5";
}
if($_SESSION['type']==1){
$l=$_SESSION['labid'];
$query = "SELECT * FROM comment_sta WHERE labid='$l' ORDER BY comment_id DESC LIMIT 5";
}
if($_SESSION['type']==2){
$l=$_SESSION['labid'];
$query = "SELECT * FROM comment_fac WHERE labid='$l' ORDER BY comment_id DESC LIMIT 5";
}
$result = mysqli_query($con, $query);
$output = '';
if(mysqli_num_rows($result) > 0)
{
while($row = mysqli_fetch_array($result))
{
$output .= '
<li>
<a href="#">
<strong>'.$row["comment_subject"].'</strong><br />
<small><em>'.$row["comment_text"].'</em></small>
</a>
</li>
<li class="divider"></li>
';
}
$output .='<li><a href="view_msg.php">View Previous notification </a> </li>';
}
}
if($_POST["view"] != '')
{
if($_SESSION['type']==0){
$update_query = "UPDATE comments SET comment_status=1 WHERE comment_status=0 AND Id='$s'";
}
if($_SESSION['type']==1){
$update_query = "UPDATE comment_sta SET comment_status=1 WHERE comment_status=0 AND labid='$l'";
}
if($_SESSION['type']==2){
$update_query = "UPDATE comment_fac SET comment_status=1 WHERE comment_status=0 AND labid='$l'";
}
mysqli_query($con, $update_query);
}
if($_SESSION['type']==0){
$query_1 = "SELECT * FROM comments WHERE comment_status=0 AND Id='$s'";
}
if($_SESSION['type']==1){
$query_1 = "SELECT * FROM comment_sta WHERE comment_status=0 AND labid='$l'";
}
if($_SESSION['type']==2){
$query_1 = "SELECT * FROM comment_fac WHERE comment_status=0 AND labid='$l'";
}
$result_1 = mysqli_query($con, $query_1);
$count = mysqli_num_rows($result_1);
$data = array(
'notification' => $output,
'unseen_notification' => $count
);
echo json_encode($data);
}
?>