-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathforum.php
More file actions
31 lines (27 loc) · 1.04 KB
/
forum.php
File metadata and controls
31 lines (27 loc) · 1.04 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
<?php
define("TITLE", "View Forum");
include("includes/header.php");
if (isset($_GET['id']))
$forum = htmlspecialchars($_GET['id']);
if (!isset($forum))
die("No forum selected.");
?>
<p><a href="post.php?cat=<?=$forum?>">Post a new topic</a></p>
<?php
$sql = "SELECT value FROM settings WHERE setting = 'max_topics'";
$q = mysqli_query($dbc, $sql);
$r = mysqli_fetch_array($q, MYSQLI_ASSOC);
if (mysqli_affected_rows($dbc) > 0)
$max_topics = $r["value"];
$query = "SELECT topics.id, topics.title, topics.time, users.username FROM topics INNER JOIN users ON topics.author = users.id WHERE topics.category = ? ORDER BY time ASC LIMIT {$max_topics}";
$stmt = $dbc->prepare($query);
$stmt->bind_param("s", $forum);
$stmt->execute();
$result = $stmt->get_result();
if ($result->num_rows > 0)
while ($r = $result->fetch_assoc())
print " <p><a href=\"topic.php?id={$r["id"]}\">{$r["title"]}</a><br><em>Posted by {$r["username"]} at {$r["time"]}</em></p>\n";
else
print " <p>No topics to display.</p>\n";
include("includes/footer.php");
?>