From d55089758306fd078a00d2a6d9d0fafc14a0edcf Mon Sep 17 00:00:00 2001 From: Cflip <36554078+cflip@users.noreply.github.com> Date: Sat, 23 Jan 2021 21:39:56 -0700 Subject: Implement latest post/thread columns --- index.php | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'index.php') diff --git a/index.php b/index.php index 08f4928..01acd33 100644 --- a/index.php +++ b/index.php @@ -24,25 +24,40 @@ include_once 'header.php'; die('Failure trying to display categories: ' . mysqli_error($dbc)); } + $sql = "SELECT thread_id, thread_subject, thread_date, user_id, user_name FROM threads JOIN users ON thread_author = user_id WHERE thread_cat = ? ORDER BY thread_id DESC LIMIT 1"; + $stmt = mysqli_stmt_init($dbc); + + if (!mysqli_stmt_prepare($stmt, $sql)) { + die('Could not create thread due to internal error: ' . mysqli_error($dbc)); + } + while ($row = mysqli_fetch_assoc($result)) { + mysqli_stmt_bind_param($stmt, "i", $row['cat_id']); + mysqli_stmt_execute($stmt); + + $thread_res = mysqli_stmt_get_result($stmt); + $thread = mysqli_fetch_assoc($thread_res); + echo ''; echo '

' . $row['cat_name'] . '

'; echo $row['cat_description']; - echo 'Example thread
1 hour ago by example user'; + echo '' . $thread['thread_subject'] . '
'; + echo 'by ' . $thread['user_name'] . ''; } + mysqli_stmt_close($stmt); mysqli_free_result($result); ?> - + '; + echo 'by ' . $row['user_name'] . ' on ' . date('M d, Y', strtotime($row['thread_date'])) . ''; } mysqli_free_result($result); -- cgit v1.2.3
Latest ThreadsLatest PostCategories
'; echo '

' . $row['thread_subject'] . '

'; - echo 'by ' . $row['user_name'] . ' on ' . date('M d, Y', strtotime($row['thread_date'])) . '
by cflip
01-22-2021 9:34
Posted in ' . $row['cat_name'] .'