-
Notifications
You must be signed in to change notification settings - Fork 0
/
loadmsg.php
47 lines (42 loc) · 861 Bytes
/
loadmsg.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
<?php
session_start();
$user=$_SESSION['username'];
$recid=$_SESSION["recid"];
require 'connect.php';
if($con)
{
$query="SELECT * FROM (SELECT * from messages where (((too='$recid') and (fromm='$user')) or ((too='$user') and (fromm='$recid'))) ORDER by clock DESC limit 6)messages order by clock ASC";
$res=mysqli_query($con,$query);
if($res)
{
$i=0;
$number=mysqli_num_rows($res);
if($number>0)
{
while ($data=mysqli_fetch_assoc($res))
{
if($data["fromm"]==$user)
{
echo "<div class='umessage' id='$data[id]' ><span>".$data["message"]."<p></span></div>";
}
else {
# code..
echo "<div class='omessage' id='$data[id]' ><span>".$data["message"]."<p></span></div>";
}
}
}
else
{
echo "no messseges";
}
}
else
{
echo " query not executed";
}
}
else{
// echo "query not executed";
echo "cannot connect to the database";
}
?>