-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathfeed.php
More file actions
27 lines (25 loc) · 789 Bytes
/
feed.php
File metadata and controls
27 lines (25 loc) · 789 Bytes
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
<?php
//Written by Chris Hogan
//This file checks the database for notifications and sends them
//to displayNotifications.js for rendering.
session_start();
error_reporting(E_ALL);
ini_set('display_errors','1');
require_once('php_includes/dbAccess.php');
$c = dbConnect();
$uname = $_SESSION['username'];
$x = "SELECT * FROM Notifications WHERE toUser='$uname'";
$result = mysqli_query($c,$x);
$results = Array();
$i = 0;
while($row = mysqli_fetch_array($result)) {
$results[$i] = $row;
$i++;
}
echo json_encode($results);
//Now we need to set the 'displayed' value of the displayed
//notifications to 'true' so they will only appear once.
$q = "UPDATE Notifications SET displayed='true' WHERE toUser='$uname'";
$sql = mysqli_query($c, $q);
mysqli_close($c);
?>