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
|
<?php
include_once 'includes/db_inc.php';
include_once 'model/Category.php';
session_start();
$current = new Category();
if (!isset($_GET['id']) || !filter_var($_GET['id'], FILTER_VALIDATE_INT)) {
} else {
$current->get_from_database($_GET['id'], $dbc);
}
?>
<!DOCTYPE html>
<html>
<head>
<title><?php echo $current->name; ?> - cflip.net forum</title>
</head>
<body style="width: 720px;margin: auto;">
<?php include_once 'templates/header.php';?>
<h1><?php echo $current->name; ?></h1>
<p><?php echo $current->description; ?></p>
<?php echo $current->thread_count . ' threads, ' . $current->post_count . ' posts'; ?>
<h2>Threads</h2>
<table width="100%">
<tr>
<th>Thread Name</th>
<th>Latest Post</th>
</tr>
<?php
include_once 'includes/db_inc.php';
$threads = current->get_threads();
for each thread {
$thread->get_latest_post();
}
$sql = "
SELECT thread_id, thread_subject, thread_date_created, thread_date_lastpost, thread_category, thread_author, user_id, user_name
FROM threads
LEFT JOIN users
ON thread_author = user_id
WHERE thread_category = " . $_GET['id'];
$result = mysqli_query($dbc, $sql);
if (!$result) {
die('Error trying to display posts: ' . mysqli_error($dbc));
}
if (mysqli_num_rows($result) == 0) {
echo 'No categories found!';
} else {
while ($row = mysqli_fetch_assoc($result)) {
echo '<tr>';
echo '<td><b><a href="../thread/' . $row['thread_id'] . '">' . $row['thread_subject'] . '</a></b><br>';
echo '<small>by ' . $row['user_name'] . ' on ' . date('M d, Y', strtotime($row['thread_date_created'])) . '</small></td>';
echo '<td>' . date('M d, Y', strtotime($row['thread_date_lastpost'])) . '</td>';
echo '</tr>';
}
}
?>
</table>
</body>
</html>
|