-
Notifications
You must be signed in to change notification settings - Fork 4
/
old_chat_autoload.php
48 lines (33 loc) · 1.78 KB
/
old_chat_autoload.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
<?php
session_start();
include"database_connection.php";
$user1=$_SESSION["self_user"];
$user2=$_SESSION["other_user"];
$other_user=$_SESSION["other_user"];
if(strcmp($user1,$user2)>0){
$user2=$_SESSION["self_user"];
$user1=$_SESSION["other_user"];
};
$change_lue_value="UPDATE messages SET LUE = 1 WHERE user1='$user1' and user2 = '$user2' and sender = '$other_user'";
$execute_query=mysqli_query($link,$change_lue_value);
$chat_query="select * from messages where user1='$user1' and user2 = '$user2'";
$execute_chat_query=mysqli_query($link,$chat_query);
while($rows = mysqli_fetch_array($execute_chat_query)) :
echo"<ul>";
if($rows['type_message']==0){
if($rows['sender'] == $_SESSION['self_user']){
echo "<li class=\"sent\"> <img class=\"profile_image\" src=\"pictures/".$_SESSION['self_user'].".png\" alt='me'/> <p class=\"chat-message\">".$rows["message"]."</p> </li> ";
}else{
echo " <li class=\"replies\"> <img class=\"profile_image\" src=\"pictures/".$_SESSION['other_user'].".png\" alt='him'/> <p class=\"chat-message\">".$rows["message"]."</p> </li> ";
}
}
else{
if($rows['sender'] == $_SESSION['self_user']){
echo "<li class=\"sent\"> <img class=\"profile_image\" src=\"pictures/".$_SESSION['self_user'].".png\" alt='me'/> <p class=\"chat-message\"><img id='chat_image' style='cursor: pointer' src='".$rows["message"]."' alt='me'></p> </li> ";
}else{
echo " <li class=\"replies\"> <img class=\"profile_image\" src=\"pictures/".$_SESSION['self_user'].".png\" alt='me'/> <p class=\"chat-message\"><img id='chat_image' style='cursor: pointer' src='".$rows["message"]."' alt='me'></p> </li> ";
}
}
echo"</ul>";
endwhile;
?>