forked from CSS-Tricks/Chat2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchatrooms.php
More file actions
78 lines (51 loc) · 1.88 KB
/
chatrooms.php
File metadata and controls
78 lines (51 loc) · 1.88 KB
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
<?php
session_start();
require_once("dbcon.php");
require_once("include/conexion/conexion.php");
if (checkVar($_SESSION['userid'])):
$getRooms = "SELECT *
FROM chat_rooms";
$resultado = $base->prepare( $getRooms );
$resultado->execute( array() );
$resultado = $resultado->fetchAll( PDO::FETCH_OBJ );
?>
<!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="css/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']?></div>
</div>
<div id="section">
<div id="rooms">
<h3>Rooms</h3>
<ul>
<?php
foreach($resultado as $room):
$query = "SELECT * FROM `chat_users_rooms` WHERE `room` = '$room->name' ";
$resultado = $base->prepare( $query );
$resultado->execute( array() );
$numOfUsers = $resultado->rowCount();
$resultado = null;
?>
<li>
<a href="room/?name=<?php echo $room->name?>"><?php echo $room->name . "<span>Users chatting: <strong>" . $numOfUsers . "</strong></span>" ?></a>
</li>
<?php endforeach; ?>
</ul>
</div>
</div>
</div>
</body>
</html>
<?php
else:
header('Location: http://css-tricks.com/examples/Chat2/');
endif;
?>