forked from CSS-Tricks/Chat2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchatrooms.php
68 lines (45 loc) · 1.92 KB
/
chatrooms.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
<?php
require_once("dbcon.php");
if (checkVar($_SESSION['userid'])):
$getRooms = "SELECT *
FROM chat_rooms";
$roomResults = mysql_query($getRooms);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Chat Rooms</title>
<link rel="stylesheet" type="text/css" href="main.css"/>
</head>
<body>
<div id="page-wrap">
<div id="header">
<h1><a href="/examples/Chat2/">Chat v2</a></h1>
<div id="you"><span>Logged in as:</span> <?php echo $_SESSION['userid']?><a href="out.php"><img onmouseover="javascript:this.src='images/outover.png';" onmouseout="javascript:this.src='images/out.png';" src="images/out.png" /></a></div>
</div>
<div id="section">
<div id="rooms">
<h3>Rooms</h3>
<ul>
<?php
while($rooms = mysql_fetch_array($roomResults)):
$room = $rooms['name'];
$query = mysql_query("SELECT * FROM `chat_users_rooms` WHERE `room` = '$room' ") or die("Cannot find data". mysql_error());
$numOfUsers = mysql_num_rows($query);
?>
<li>
<a href="room/?name=<?php echo utf8_encode($rooms['name'])?>"><?php echo utf8_encode($rooms['name']) . "<span>Users chatting: <strong>" . $numOfUsers . "</strong></span>" ?></a>
</li>
<?php endwhile; ?>
</ul>
</div>
</div>
</div>
</body>
</html>
<?php
else:
header('Location: http://css-tricks.com/examples/Chat2/');
endif;
?>