summaryrefslogtreecommitdiff
path: root/model/Category.php
diff options
context:
space:
mode:
authorcflip <36554078+cflip@users.noreply.github.com>2021-03-24 18:29:41 -0600
committercflip <36554078+cflip@users.noreply.github.com>2021-03-24 18:29:41 -0600
commitc9732788143886b611cb2fecfb53daf3d8add48f (patch)
tree8dd3152611bf59cc4982be9839e340ec89d0bee2 /model/Category.php
parent9c619586639b9ac0f107e63a54b5522d75ea2ee2 (diff)
Show latest thread/post on pages
Diffstat (limited to 'model/Category.php')
-rw-r--r--model/Category.php22
1 files changed, 22 insertions, 0 deletions
diff --git a/model/Category.php b/model/Category.php
index ffd903c..4e57f46 100644
--- a/model/Category.php
+++ b/model/Category.php
@@ -54,6 +54,28 @@ class Category {
mysqli_free_result($result);
return $threads;
}
+
+ function get_latest_thread($dbc) {
+ $sql = "SELECT thread_id FROM threads WHERE thread_category = " . $this->id . " ORDER BY thread_date_lastpost DESC LIMIT 1";
+ $result = mysqli_query($dbc, $sql);
+
+ if (!$result) {
+ echo 'Could not get thread from category: ' . mysqli_error($dbc);
+ }
+
+ $thread = null;
+
+ if (mysqli_num_rows($result) == 0) {
+ } else {
+ while ($row = mysqli_fetch_assoc($result)) {
+ $thread = new Thread();
+ $thread->get_from_database($row['thread_id'], $dbc);
+ }
+ }
+
+ mysqli_free_result($result);
+ return $thread;
+ }
}
function get_all_categories($dbc) {