-
Notifications
You must be signed in to change notification settings - Fork 0
/
get_message.php
38 lines (18 loc) · 923 Bytes
/
get_message.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
<?php
include("server.php");
session_start();
$username = $_SESSION['username'];
$userid = $_SESSION['userid'];
$tempQuery = "select login.username, message.message, message.timestamp from login inner join message on login.id = message.userid inner join history on history.userid = login.id where message.timestamp > (select timestamp from history where history.userid =".$userid.")";
// $tempQuery = "SELECT * FROM message";
$result = mysql_query($tempQuery) or die("Error: ".mysql_error());;
$updateLastActive = "UPDATE history SET requestno = requestno +1 WHERE userid IN ( SELECT id FROM login WHERE username ='".$username."')";
$updateResult = mysql_query($updateLastActive) or die("Error: ".mysql_error());
$data = array();
while($meassage_rows = mysql_fetch_array($result))
{
$data[] = $meassage_rows;
}
header('Content-Type: application/json');
print json_encode($data);
?>