-
Notifications
You must be signed in to change notification settings - Fork 32
/
chatdisplay.php
92 lines (69 loc) · 1.81 KB
/
chatdisplay.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
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<style>
.chatmsg
{
background-color:#075bff;
border: 1px solid #075bff;
border-radius: 10px;
height:100px;
width:100px;
padding: 8px;
color: white;
}
.adchatmsg
{
background-color: #5FCF80;
border: 1px solid #5FCF80;
border-radius: 10px;
height:100px;
width:100px;
padding: 8px;
color: white;
}
.time
{
color: white;
font-size: 12px;
}
img
{
width:40px;
display: inline;
height: 40px;
border-radius: 50%;
border:2px solid white;
}
</style>
<!--to send message-->
<?php
if($_SERVER['REQUEST_METHOD']=="GET")//con establish
{
$localhost = "localhost";
$usernamew = "root";
$passwordw = "";
$db = "expdb";
$conn = mysqli_connect($localhost,$usernamew,$passwordw,$db);
if(!$conn){
echo "";
}
else
{
echo "";
}
$sql = "Select * from chattable order by time desc";
$result = mysqli_query($conn,$sql);
if (mysqli_num_rows($result) > 0)
{
while($row = mysqli_fetch_assoc($result))
{
if($row["username"]=='admin')
{
echo "<span class='adchatmsg'><img src='admin.jpg'> ".$row["message"]."<span class='time'>".substr($row["time"],8)."</span></span><br><br>";
}
else
{
echo "<span class='chatmsg'><img src='deafaultuser.jpg'> ".$row["message"]."<span class='time'>".substr($row["time"],8)."</span></span><br><br>";
}
}
}
}
?>