blob: fcc7851c708fd75f2735d643b24e13155316f9ef (
plain)
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
|
<?php
include_once 'includes/db_inc.php';
include_once 'header.php';
echo '<section>';
$sql = "SELECT cat_name, cat_description FROM categories WHERE cat_id = " . mysqli_real_escape_string($dbc, $_GET['id']);
$result = mysqli_query($dbc, $sql);
if (!$result) {
die('Error trying to display category: ' . mysqli_error($dbc));
}
// Display category name and description
if (mysqli_num_rows($result) == 0) {
echo 'This category does not exist';
} else {
while ($row = mysqli_fetch_assoc($result)) {
echo '<h1>' . $row['cat_name'] . '</h1>';
echo $row['cat_description'];
}
}
mysqli_free_result($result);
echo '</section>';
$sql = "SELECT thread_id, thread_subject, thread_date, user_name FROM threads LEFT JOIN users ON thread_author = user_id WHERE thread_cat = " . mysqli_real_escape_string($dbc, $_GET['id']) . " ORDER BY thread_id DESC";
$result = mysqli_query($dbc, $sql);
if (!$result) {
die('Error trying to display threads: ' . mysqli_error($dbc));
}
// Display table of posts
echo '<table><tr><th class="left">Thread</th><th class="right">Latest Post</th></tr>';
while ($row = mysqli_fetch_assoc($result)) {
echo '<tr><td class="left">';
echo '<h4><a href="thread.php?id=' . $row['thread_id'] . '">' . $row['thread_subject'] . '</a></h4>';
echo '<small>by <b>' . $row['user_name'] . '</b> on ' . date('M d, Y', strtotime($row['thread_date'])) . '</small></td><td class="right">by <b>cflip</b><br><small>01-22-2021 9:34</small></td></tr>';
}
echo '</table>';
include 'footer.php';
|