-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstudentChatRoom.php
More file actions
150 lines (141 loc) · 9.22 KB
/
studentChatRoom.php
File metadata and controls
150 lines (141 loc) · 9.22 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
<?php
require_once 'include/header2.php';
?>
<div class="container-fluid body-section mt-5 pt-5">
<div class="row">
<div class="col-md-3">
<?php
require_once 'include/sidebar2.php';
$chatRoomName = $_GET['chatRoomName'];
$findChatRoom = "SELECT * FROM messages WHERE videoTitle='$chatRoomName'";
$runQuery = mysqli_query($conn, $findChatRoom);
$row10 = mysqli_fetch_assoc($runQuery);
$videoId = $row10['videoId'];
?>
</div>
<div class="col-md-9">
<h1><i class="fas fa-users"></i> Student <small>Profile Overview</small></h1>
<hr>
<ol class="breadcrumb">
<li class="breadcrumb-item active"><i class="fas fa-tachometer-alt"></i> Profile</li>
</ol>
<hr>
<h1 class="pb-3">Video Chat Rooms:</h1>
<main class="content">
<div class="container-fluid p-0">
<h1 class="h3 mb-3">Messages</h1>
<div class="card">
<div class="row g-0">
<div class="col-lg-12">
<div class="py-2 px-4 border-bottom d-none d-lg-block">
<div class="d-flex align-items-center py-1">
<div class="flex-grow-1 pl-3">
<strong>VIDEO ADDITION IN HTML CHAT ROOM:</strong>
</div>
</div>
</div>
<div class="position-relative">
<div class="chat-messages p-4">
<?php
$studentUid = $_SESSION['useruid'];
$chatRoomName = $_GET['chatRoomName'];
$query = "SELECT * FROM teacher t INNER JOIN messages m ON t.teacherUid=m.senderUid WHERE videoTitle='$chatRoomName'";
$run = mysqli_query($conn, $query);
if (mysqli_num_rows($run) > 0) {
?>
<?php
while ($row = mysqli_fetch_array($run)) {
$senderUid = $row['senderUid'];
$senderMessage = $row['senderMessage'];
$messageTime = $row['messageTime'];
?>
<div class="chat-message-left pb-4">
<div>
<img src="https://bootdey.com/img/Content/avatar/avatar3.png" class="rounded-circle mr-1" alt="Sharon Lessman" width="40" height="40">
<div class="text-muted small text-nowrap mt-2"><?php echo $messageTime; ?></div>
</div>
<div class="flex-shrink-1 bg-light rounded py-2 px-3 ml-3">
<div class="font-weight-bold mb-1">
<p style="color: red;"><?php echo $senderUid; ?>: Teacher</p>
</div>
<p><?php echo $senderMessage; ?></p>
</div>
</div>
<?php
}
?>
<?php
} else {
echo "<center><h2>No response from teacher right now</h2></center>";
}
?>
<?php
$query = "SELECT * FROM student s INNER JOIN messages m ON s.studentUid=m.senderUid WHERE videoTitle='$chatRoomName' AND s.studentUid!='$studentUid'";
$run = mysqli_query($conn, $query);
if (mysqli_num_rows($run) > 0) {
?>
<?php
while ($row = mysqli_fetch_array($run)) {
$senderUid = $row['senderUid'];
$senderMessage = $row['senderMessage'];
$messageTime = $row['messageTime'];
?>
<div class="chat-message-left pb-4">
<div>
<img src="https://bootdey.com/img/Content/avatar/avatar3.png" class="rounded-circle mr-1" alt="Sharon Lessman" width="40" height="40">
<div class="text-muted small text-nowrap mt-2"><?php echo $messageTime; ?></div>
</div>
<div class="flex-shrink-1 bg-light rounded py-2 px-3 ml-3">
<div class="font-weight-bold mb-1"><?php echo $senderUid; ?></div>
<p><?php echo $senderMessage; ?></p>
</div>
</div>
<?php
}
?>
<?php
} else {
echo "<center><h2>No response from other student right now</h2></center>";
}
?>
<?php
$query = "SELECT * FROM messages WHERE senderUid ='$studentUid' AND videoTitle='$chatRoomName'";
$run = mysqli_query($conn, $query);
while ($row = mysqli_fetch_array($run)) {
$senderUid = $row['senderUid'];
$senderMessage = $row['senderMessage'];
$messageTime = $row['messageTime'];
?>
<div class="chat-message-right pb-4">
<div>
<img src="https://bootdey.com/img/Content/avatar/avatar1.png" class="rounded-circle mr-1" alt="Chris Wood" width="40" height="40">
<div class="text-muted small text-nowrap mt-2"><?php echo $messageTime; ?></div>
</div>
<div class="flex-shrink-1 bg-light rounded py-2 px-3 mr-3">
<div class="font-weight-bold mb-1"><?php echo $senderUid; ?></div>
<?php echo $senderMessage; ?>
</div>
</div>
<?php
} ?>
</div>
</div>
<div class="flex-grow-0 py-3 px-4 border-top">
<form action="include/studentResponse.inc.php?videoTitle=<?php echo $chatRoomName; ?>&videoId=<?php echo $videoId; ?>" method="post">
<div class="input-group">
<textarea class="form-control" name="message" id="" cols="50" rows="5" placeholder="Type message here" required></textarea>
<button class="btn btn-sm btn-primary text-uppercase" type="submit" name="submit">Send</button>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</main>
</div>
</div>
</div>
<?php
require_once 'include/footer.php';
?>