From 2805ef7311eeb028cd48bffe04a705676c4682be Mon Sep 17 00:00:00 2001 From: cflip <36554078+cflip@users.noreply.github.com> Date: Sun, 21 Mar 2021 10:54:47 -0600 Subject: big changes pt1 --- category.php | 91 ++++++++++++++++++++++++++++++++++++------------------------ 1 file changed, 55 insertions(+), 36 deletions(-) (limited to 'category.php') diff --git a/category.php b/category.php index 4280767..e559f22 100644 --- a/category.php +++ b/category.php @@ -1,46 +1,65 @@ Unknown category.'; -} else { - echo '
'; +session_start(); - $sql = "SELECT cat_name, cat_description FROM categories WHERE cat_id = " . mysqli_real_escape_string($dbc, $_GET['id']); - $result = mysqli_query($dbc, $sql); +$current = new Category(); - if (!$result) { - die('Error trying to display category: ' . mysqli_error($dbc)); - } +if (!isset($_GET['id']) || !filter_var($_GET['id'], FILTER_VALIDATE_INT)) { +} else { + $current->get_from_database($_GET['id'], $dbc); +} +?> + + + + <?php echo $current->name; ?> - cflip.net forum + + + +

name; ?>

+

description; ?>

+ thread_count . ' threads, ' . $current->post_count . ' posts'; ?> +

Threads

+ + + + + + ' . $row['cat_name'] . ''; - echo $row['cat_description']; + $threads = current->get_threads(); + for each thread { + $thread->get_latest_post(); } - } - mysqli_free_result($result); + $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']; - echo ''; - - $sql = "SELECT thread_id, thread_subject, thread_date, user_id, user_name FROM threads 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)); - } - - echo '
Thread NameLatest Post
'; - display_threads($dbc, $result); - mysqli_free_result($result); - echo '
ThreadLatest Post
'; -} + $result = mysqli_query($dbc, $sql); + + if (!$result) { + die('Error trying to display posts: ' . mysqli_error($dbc)); + } -include 'footer.php'; \ No newline at end of file + 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 ''; + } + } + ?> + + + \ No newline at end of file -- cgit v1.2.3