-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdata.php
30 lines (30 loc) · 1.48 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
30
<?php
while($row = mysqli_fetch_assoc($query)){
$sql2 = "SELECT * FROM messages WHERE (incoming_id = '{$row['unique_id']}'
OR outgoing_id = '{$row['unique_id']}') AND (outgoing_id = '{$outgoing_id}'
OR incoming_id = '{$outgoing_id}') ORDER BY id DESC LIMIT 1";
$query2 = mysqli_query($db_connection, $sql2);
$row2 = mysqli_fetch_assoc($query2);
(mysqli_num_rows($query2) > 0) ? $result = $row2['message_content'] : $result ="No message available";
(strlen($result) > 28) ? $msg = substr($result, 0, 28) . '...' : $msg = $result;
if(isset($row2['incoming_id'])){
($outgoing_id == $row2['outgoing_id']) ? $you = "You: " : $you = "";
}else{
$you = "";
}
($row['Status'] == "Offline now") ? $offline = "offline" : $offline = "";
($outgoing_id == $row['id']) ? $hid_me = "hide" : $hid_me = "";
$newDateTime = date('h:i A', strtotime($row2['created_at']));
$output .= '<a href="chatscreen.php?email_id='. $row['email'] .'">
<div class="content">
<div class="details">
<span>'. $row['username'].'</span>
<div class="message_details">
<p>'. $you . $msg .'</p>
<p class="last_time">'.$newDateTime.'</p>
</div>
</div>
</div>
</a>';
}
?>