-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfetch_user.php
56 lines (44 loc) · 1.32 KB
/
fetch_user.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
<?php
//fetch_user.php
include('database_connection.php');
session_start();
$query = "
SELECT * FROM login
WHERE user_id != '".$_SESSION['user_id']."'
";
$statement = $connect->prepare($query);
$statement->execute();
$result = $statement->fetchAll();
$output = '
<table class="table table-bordered table-striped">
<tr>
<th width="70%">Username</td>
<th width="20%">Status</td>
<th width="10%">Action</td>
</tr>
';
foreach($result as $row)
{
$status = '';
$current_timestamp = strtotime(date("Y-m-d H:i:s") . '- 10 second');
$current_timestamp = date('Y-m-d H:i:s', $current_timestamp);
$user_last_activity = fetch_user_last_activity($row['user_id'], $connect);
if($user_last_activity > $current_timestamp)
{
$status = '<span class="label label-success">Online</span>';
}
else
{
$status = '<span class="label label-danger">Offline</span>';
}
$output .= '
<tr>
<td>'.$row['username'].' '.count_unseen_message($row['user_id'], $_SESSION['user_id'], $connect).' '.fetch_is_type_status($row['user_id'], $connect).'</td>
<td>'.$status.'</td>
<td><button type="button" class="btn btn-info btn-xs start_chat" data-touserid="'.$row['user_id'].'" data-tousername="'.$row['username'].'">Start Chat</button></td>
</tr>
';
}
$output .= '</table>';
echo $output;
?>