-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathviewtopics.php
93 lines (74 loc) · 2.9 KB
/
viewtopics.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
93
<?php
// Start the session
require_once('startsession.php');
// Insert the page header
$page_title = 'View Topics';
require_once('header.php');
require_once('appvars.php');
// Database connection variables:
require_once('dbconnect.php');
// Make sure the user is logged in before going any further.
if (!isset($_SESSION['user_id'])) {
echo '<p class="login">Please <a href="login.php">log in</a> to access this page.</p>';
exit();
}
// Show the navigation menu
require_once('navmenu.php');
// Connect to the database
$dbc = db_connect();
// Store topic name and id from the GET data:
$topicID = $_GET['topic_id'];
$topicName = $_GET['name'];
?>
<div class="TenPxPaddingDiv">
<!-- Output the name of the current Topic -->
<?php echo '<h1><a href="chat.php?topic_name=' . $topicName . '&topic_id=' . $topicID .'">' . 'Chat about ' . $topicName . '<br></a></h1>'; ?>
<h1>Users with an interest in <?php echo $topicName; ?>:</h1>
<!-- TODO: List the users from this topic that are in the database: -->
<?php
// Create query to get all users for current topic:
// $queryAllUsersInTopic = "SELECT user_id FROM mismatch_user_topic
// WHERE topic_id =" . $topicID;
$queryAllUsersTopicAndInfo =
"SELECT mismatch_user_topic.user_id, mismatch_user_topic.topic_id,
mismatch_user.user_id, mismatch_user.username,
CONCAT_WS(' ', mismatch_user.first_name, mismatch_user.last_name) AS 'whole_name',
mismatch_user.gender,
CONCAT_WS(', ', mismatch_user.city, mismatch_user.state) AS 'city_state',
mismatch_user.picture, mismatch_user.chat_status
FROM mismatch_user_topic
INNER JOIN mismatch_user
ON mismatch_user_topic.user_id = mismatch_user.user_id
WHERE topic_id =" . $topicID . " ORDER BY mismatch_user.chat_status DESC,
mismatch_user.last_name" ;
// Store/execute query:
$dataAllUsersInTopic = mysqli_query($dbc, $queryAllUsersTopicAndInfo);
while ($row = mysqli_fetch_array($dataAllUsersInTopic)){
echo 'Username: ' . $row['username'] . '<br>';
echo 'Name: ' . $row['whole_name'] . '<br>';
echo 'Gender: ' . $row['gender'] . '<br>';
echo 'city/state: ' . $row['city_state'] . '<br>';
// Determine chat availability:
if($row['chat_status']){
echo '<a href="chat.php?topic_name=' . $topicName .
'&topic_id=' . $topicID .
'">chat status: Online<br></a>';
}else{
echo "chat status: Offline<br>";
}
// If the image is there, display it, otherwise display the placeholder
// 'no image' image.
if(!empty($row['picture'])){
echo '<img class="profile" src="' . MM_UPLOADPATH . $row['picture'] .
'" alt="Profile Picture" /><br><br><br>';
}else{
echo '<img class="profile" src="' . MM_UPLOADPATH . 'nopic.jpg' .
'" alt="No Profile Picture" /><br><br><br>';
}
}
?>
</div>
<?php
// Insert the page footer
require_once('footer.php');
?>