-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathchatrefresh.php
More file actions
73 lines (62 loc) · 2.24 KB
/
Copy pathchatrefresh.php
File metadata and controls
73 lines (62 loc) · 2.24 KB
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php
if(sizeof($_POST)>0){
$servername="localhost";
$username="root";
$password="";
$dbName="chatting-system";
$port="3308";
$conn = mysqli_connect($servername, $username, $password, $dbName, $port);
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
// var_dump($_POST);
$sen=$_POST["sender"];
$rev=$_POST["receiver"];
$date=$_POST["date"];
// $time=$_POST["time"];
$sendQuery="select * from users left join chat_content on chat_content.senderId = users.id where (chat_content.senderId = ".$sen." and chat_content.receiverId = ".$rev.") or (chat_content.senderId = ".$rev." and chat_content.receiverId = ".$sen.") order by(chat_content.id)";
$final = mysqli_query($conn, $sendQuery);
if (mysqli_num_rows($final) > 0) {
while($rowSend = mysqli_fetch_assoc($final)) {
$datePicker=$rowSend["current_time"];
$date = date('g:i a',strtotime($datePicker));
// if($rowSend["current_time"]>0){
// $today = date('d/m/yy',strtotime($datePicker));
// }
// if($date<=$today){
// echo $today;
// }else if($date>=$today){
// echo $today;
// }
if($sen==$rowSend["senderId"]){
$firstname = strtok($rowSend["uname"],' ');
echo '<div class="vW7d1 message-out div-space">' .
'<div class="name-send">' . $firstname . '</div>' .
'<div class="sender">' .
'<div class="message-box">' .
'<span>' . $rowSend["content"] . '</span>' .
'</div>' .
'<div class="timer-box">' .
'<span>' . $date . '</span>' .
'</div>' .
'</div>' .
'</div>';
}else {
$firstname = strtok($rowSend["uname"], ' ');
echo '<div class="vW7d1 message-in div-space">' .
'<div class="name-out">' . $firstname . '</div>' .
'<div class="receiver">' .
'<div class="message-box">' .
'<span>' . $rowSend["content"] . '</span>' .
'</div>' .
'<div class="timer-box">' .
'<span>' . $date . '</span>' .
'</div>' .
'</div>' .
'</div>';
}
}
}
mysqli_close($conn);
}
?>