-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdata.php
29 lines (28 loc) · 1.46 KB
/
data.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
<?php
while($row = mysqli_fetch_assoc($query)){
$sql2 = "SELECT * FROM messages WHERE (incoming_msg_id = {$row['unique_id']}
OR outgoing_msg_id = {$row['unique_id']}) AND (outgoing_msg_id = {$outgoing_id}
OR incoming_msg_id = {$outgoing_id}) ORDER BY msg_id DESC LIMIT 1";
$query2 = mysqli_query($conn, $sql2);
$row2 = mysqli_fetch_assoc($query2);
(mysqli_num_rows($query2) > 0) ? $result = $row2['msg'] : $result ="No message available";
(strlen($result) > 28) ? $msg = substr($result, 0, 28) . '...' : $msg = $result;
if(isset($row2['outgoing_msg_id'])){
($outgoing_id == $row2['outgoing_msg_id']) ? $you = "You: " : $you = "";
}else{
$you = "";
}
($row['status'] == "Offline now") ? $offline = "offline" : $offline = "";
($outgoing_id == $row['unique_id']) ? $hid_me = "hide" : $hid_me = "";
$output .= '<a href="chat.php?user_id='. $row['unique_id'] .'">
<div class="content">
<img src="php/images/'. $row['img'] .'" alt="">
<div class="details">
<span>'. $row['fname']. " " . $row['lname'] .'</span>
<p>'. $you . $msg .'</p>
</div>
</div>
<div class="status-dot '. $offline .'"><i class="fas fa-circle"></i></div>
</a>';
}
?>