diff options
Diffstat (limited to 'category.php')
-rw-r--r-- | category.php | 38 |
1 files changed, 8 insertions, 30 deletions
diff --git a/category.php b/category.php index e559f22..a71029e 100644 --- a/category.php +++ b/category.php @@ -16,7 +16,7 @@ if (!isset($_GET['id']) || !filter_var($_GET['id'], FILTER_VALIDATE_INT)) { <head> <title><?php echo $current->name; ?> - cflip.net forum</title> </head> -<body style="width: 720px;margin: auto;"> +<body> <?php include_once 'templates/header.php';?> <h1><?php echo $current->name; ?></h1> <p><?php echo $current->description; ?></p> @@ -28,36 +28,14 @@ if (!isset($_GET['id']) || !filter_var($_GET['id'], FILTER_VALIDATE_INT)) { <th>Latest Post</th> </tr> <?php - include_once 'includes/db_inc.php'; + $threads = $current->get_threads($dbc); - $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>'; - } + foreach ($threads as $thread) { + echo '<tr>'; + echo '<td><b><a href="../thread/' . $thread->id . '">' . $thread->subject . '</a></b><br>'; + echo '<small>by ' . $thread->author->name . ' on ' . date('M d, Y', strtotime($thread->date_created)) . '</small></td>'; + echo '<td>' . date('M d, Y', strtotime($thread->date_lastpost)) . '</td>'; + echo '</tr>'; } ?> </table> |