-
Notifications
You must be signed in to change notification settings - Fork 0
/
threadmessages2.php
146 lines (117 loc) · 3.64 KB
/
threadmessages2.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
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
<?php
include 'database_connection.php';
if (session_status() == PHP_SESSION_NONE) {
session_start();
}
if(!isset($_SESSION['username']))
{
header("location:login.php");
}
$flag=1;
$sql = "select subject from thread where threadid = '".$_SESSION['threadid']."'";
$result = mysqli_query($conn,$sql);
$row = mysqli_fetch_row($result);
echo "<h2 align='center' >Subject: ". $row[0]."</h2>";
echo "<a href='threads.php'> <- Back to threads Page</a>";
if (isset($_SESSION['threadid']) && $flag){
$flag=0;
#unset($_POST['send']);
$idval= $_SESSION['threadid'];
$sql = "select replierid, body from threadmessages where threadid='".$idval."' order by replytimestamp";
$result = mysqli_query($conn,$sql);
if (!$result) {
printf("Error: %s\n", mysqli_error($conn));
exit();
}
echo "<div align='center' width='70%'>
<input style='text-align:center;' type='text' id='myInput' onkeyup='myFunction()' placeholder='Search message'>
</div>";
echo "<table id='messagetable' align='center'>";
//echo "<div align='center'>";
while($row = mysqli_fetch_array($result)) {
//echo "<div style='height:10px; width:100%; clear:both;'></div>";
if($row['replierid'] == $_SESSION['username'] ){
echo "<tr><td><div style='height:10px; width:100%; clear:both;'></div></td></tr>";
echo "<tr><td><div align='right' style='width:100%;border-style: outset;'>".$row['body']."</div></td></tr>";
}
else{
echo "<tr><td><div style='height:10px; width:100%;'><p align='left'><b>". $row['replierid']."</b></p></div></td></tr>";
echo "<tr><td><div style='border-style: outset;width:100%;'><p align='left'>".$row['body']."</p></div></td></tr>";
}
}
echo "</table>";
echo "<div style='height:10px; width:100%; clear:both;'></div>";
echo "<div align='center'>
<form action='messagetodb.php' method='post' style='width:40%; border-style: solid;padding : 5px;'>
<fieldset>
<legend>Reply</legend>
<input type='text' name='replymessage' style='width: 440px;'>
<input class='btn btn-info' type='submit' name='send' value='Send'>
<div style='height:10px; width:100%; clear:both;'></div>
</fieldset>
</form> </div>";
if(isset($_POST['send'])){
$flag=1;
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title></title>
<style type="text/css">
* {
box-sizing: border-box;
}
#myInput {
background-image: url('/searchicon.png');
background-position: 10px 12px;
background-repeat: no-repeat;
width: 30%;
font-size: 16px;
padding: 12px 20px 12px 40px;
border: 1px solid #ddd;
margin-bottom: 12px;
}
#messagetable {
text-align: center;
border-collapse: collapse;
width: 50%;
border: 1px solid #ddd;
font-size: 18px;
}
#messagetable th, #myTable td {
text-align: left;
padding: 12px;
}
#messagetable tr {
border-bottom: 1px solid #ddd;
}
#messagetable tr.header, #myTable tr:hover {
background-color: #f1f1f1;
}
</style>
<script>
function myFunction() {
var input, filter, table, tr, td, i, txtValue;
input = document.getElementById("myInput");
filter = input.value.toUpperCase();
table = document.getElementById("messagetable");
tr = table.getElementsByTagName("tr");
for (i = 0; i < tr.length; i++) {
td = tr[i].getElementsByTagName("td")[0];
if (td) {
txtValue = td.textContent || td.innerText;
if (txtValue.toUpperCase().indexOf(filter) > -1) {
tr[i].style.display = "";
} else {
tr[i].style.display = "none";
}
}
}
}
</script>
</head>
<body>
</body>
</html>