From c84215091e914c81937c3aad2f1fd1775f556aa6 Mon Sep 17 00:00:00 2001 From: cflip <36554078+cflip@users.noreply.github.com> Date: Sun, 21 Mar 2021 17:37:13 -0600 Subject: Changes from procedural to OOP --- category.php | 38 ++++++++------------------------------ 1 file changed, 8 insertions(+), 30 deletions(-) (limited to 'category.php') 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)) { <?php echo $current->name; ?> - cflip.net forum - +

name; ?>

description; ?>

@@ -28,36 +28,14 @@ if (!isset($_GET['id']) || !filter_var($_GET['id'], FILTER_VALIDATE_INT)) { Latest Post 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 ''; - echo '' . $row['thread_subject'] . '
'; - echo 'by ' . $row['user_name'] . ' on ' . date('M d, Y', strtotime($row['thread_date_created'])) . ''; - echo '' . date('M d, Y', strtotime($row['thread_date_lastpost'])) . ''; - echo ''; - } + foreach ($threads as $thread) { + echo ''; + echo '' . $thread->subject . '
'; + echo 'by ' . $thread->author->name . ' on ' . date('M d, Y', strtotime($thread->date_created)) . ''; + echo '' . date('M d, Y', strtotime($thread->date_lastpost)) . ''; + echo ''; } ?> -- cgit v1.2.3