-
Notifications
You must be signed in to change notification settings - Fork 0
/
topic.php
153 lines (114 loc) · 3.79 KB
/
topic.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
147
148
149
150
151
152
153
<?php
session_start();
$currentuser=$_SESSION['userid'];
include 'connect.php';
include 'header.php';
?>
<!DOCTYPE html>
<html>
<head><link rel="stylesheet" href="forumstyle.css" type="text/css"></head>
<body>
<?php
$id=$_GET['id'];
$sql = "SELECT
topic_id,
topic_subject
FROM
topics
WHERE
topic_id= $id ";
$result = mysql_query($sql);
if(!$result)
{
echo 'The topic could not be displayed, please try again later.' . mysql_error();
}
else
{
if(mysql_num_rows($result) == 0)
{
echo 'This topic does not exist.';
}
else
{
while($row = mysql_fetch_assoc($result))
{
?> <h2>POSTS IN TOPIC: <?php echo $row['topic_subject'] ?></h2>
<?php
}
$sql = "SELECT
post_topic,
post_content,
post_time,
post_by,post_id
FROM
posts
WHERE
post_topic = $id ";
$result = mysql_query($sql);
if(!$result)
{
echo 'The posts could not be displayed, please try again later.';
}
else
{
if(mysql_num_rows($result) == 0)
{
echo 'There are no posts in this topic yet.';
}
else
{
echo '<div class="container">';
echo '<table border="5">
<thead>
<tr><th align="center">Posts</th>
<th>Posted at</th>
<th>Posted by</th>
</thead>';
while($row = mysql_fetch_assoc($result))
{
$user=$row['post_by'];
$query = " SELECT
user_name
FROM
user_details
WHERE
user_id =$user";
$queryresult=mysql_query($query);
$final=mysql_fetch_array($queryresult);
echo '<tr>';
echo '<td class="leftpart">';
echo '<h3>' . $row['post_content'] .'<h3>';
if($currentuser==$row['post_by'])
{
?> <a href="editpost.php?id=<?php echo $row['post_id'] ?> ">Edit </a>||<a href="deletepost.php?id=<?php echo $row['post_id'] ?> "> Delete</a><?php
}
echo '</td>';
echo '<td class="rightpart">';
echo date('d-m-Y', strtotime($row['post_time']));
echo '</td>';
echo '<td class="leftpart">';
echo $final[0];
echo '</td>';
echo '</tr>';
?>
<br>
<?php
}
?> <div id="footer" align="center">
Reply:<br>
<form method="post" action="reply.php?id=<?php echo $id?>">
<p>
<textarea name="reply-content" placeholder="Type your reply here"></textarea><br>
<input type="submit" value="Submit reply" /></p>
</form>
</div><?php echo '</div>';
?> <?php
?>
<?php
}
}
}
}
?>
</body>
</html>