-
Notifications
You must be signed in to change notification settings - Fork 0
/
messages.php
58 lines (39 loc) · 1.65 KB
/
messages.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
<?php session_start();
require("header.php");
require("checkUser.php")?>
<script type="text/javascript">
document.getElementById("amessage").className="active";
</script>
<a href="search.php">Send New Message</a>
<hr/>
<?php
//first fetch whom u have send chats
$sql = "SELECT chat_id, user_id_from, user_id_to, fullname FROM Chatmaster, user WHERE chatmaster.user_id_to=user.user_id AND chatmaster.user_id_from=$_SESSION[uid] ";
$rows = ExecuteQuery ($sql);
while ($row = mysql_fetch_array($rows))
{
echo "<a href='readmsg.php?id=$row[chat_id]'>$row[fullname]</a>";
$chatrow = mysql_fetch_array (ExecuteQuery ("SELECT * FROM chat WHERE chat_id=$row[chat_id] ORDER BY cdatetime DESC"));
if ($chatrow)
{
echo "<br/><br/> $chatrow[message]<br/>";
echo "$chatrow[cdatetime]";
}
echo "<hr style='border-top:1px solid #c3c3c3; border-bottom:1px solid white'/>";
}
// now fetch those that have sent chats to you
$sql = "SELECT chat_id, user_id_from, user_id_to, fullname FROM Chatmaster, user WHERE chatmaster.user_id_from=user.user_id AND chatmaster.user_id_to=$_SESSION[uid]";
$rows = ExecuteQuery ($sql);
while ($row = mysql_fetch_array($rows))
{
echo "<a href='readmsg.php?id=$row[chat_id]'>$row[fullname]</a>";
$chatrow = mysql_fetch_array (ExecuteQuery ("SELECT * FROM chat WHERE chat_id=$row[chat_id] ORDER BY cdatetime DESC"));
if ($chatrow)
{
echo "<br/><br/> $chatrow[message]<br/>";
echo "$chatrow[cdatetime]";
}
echo "<hr style='border-top:1px solid #c3c3c3; border-bottom:1px solid white'/>";
}
?>
<?php require("footer.php")?>