diff options
author | Cflip <36554078+cflip@users.noreply.github.com> | 2021-01-23 17:56:13 -0700 |
---|---|---|
committer | Cflip <36554078+cflip@users.noreply.github.com> | 2021-01-23 17:56:13 -0700 |
commit | 93825beae2dd7cdcaca8bdb3aace712aee85fe36 (patch) | |
tree | 281b3aa8c827cb0acaa97dfe2d8edaf6731bc370 | |
parent | 56b307dcf8ef44917e1bb6aef7a407368d13971f (diff) |
Show latest threads on index page
-rw-r--r-- | index.php | 32 |
1 files changed, 32 insertions, 0 deletions
@@ -1,6 +1,14 @@ <?php include_once 'header.php'; ?> +<section> + <h2>Welcome to the cflip.net forum!</h2> + Latest Updates: + <ul> + <li>5 latest threads are displayed on the homepage</li> + </ul> +</section> + <table> <tr> <th class="left">Category</th> @@ -26,6 +34,30 @@ include_once 'header.php'; mysqli_free_result($result); ?> </table> + <table> + <tr> + <th class="left">Latest Threads</th> + <th class="right">Latest Post</th> + </tr> +<?php + include_once 'includes/db_inc.php'; + + $sql = "SELECT thread_id, thread_subject, thread_date, user_name FROM threads LEFT JOIN users ON thread_author = user_id ORDER BY thread_id DESC LIMIT 5"; + $result = mysqli_query($dbc, $sql); + + if (!$result) { + die('Error trying to display threads: ' . mysqli_error($dbc)); + } + + while ($row = mysqli_fetch_assoc($result)) { + echo '<tr><td class="left">'; + echo '<h4><a href="thread.php?id=' . $row['thread_id'] . '">' . $row['thread_subject'] . '</a></h4>'; + echo '<small>by <b>' . $row['user_name'] . '</b> on ' . date('M d, Y', strtotime($row['thread_date'])) . '</small></td><td class="right">by <b>cflip</b><br><small>01-22-2021 9:34</small></td></tr>'; + } + + mysqli_free_result($result); +?> + </table> <?php include_once 'footer.php'; ?>
\ No newline at end of file |