From 3b0349188c83b24cb8ff7dfe76796dabc3916e83 Mon Sep 17 00:00:00 2001 From: cflip <36554078+cflip@users.noreply.github.com> Date: Wed, 7 Apr 2021 16:24:54 -0600 Subject: Styling and formatting for posts --- model/Post.php | 35 +++++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-) (limited to 'model/Post.php') diff --git a/model/Post.php b/model/Post.php index ef2fe4f..02c9dec 100644 --- a/model/Post.php +++ b/model/Post.php @@ -2,6 +2,28 @@ include_once 'Thread.php'; +function add_quote($dbc, $thread_id, $matches) { + foreach ($matches as $match) { + $id = (int) filter_var($match, FILTER_SANITIZE_NUMBER_INT); + $sql = "SELECT post_content, post_author, user_name FROM posts LEFT JOIN users ON post_author = user_id WHERE post_id = " . $id; + $result = mysqli_query($dbc, $sql); + + if (!$result) { + return '
'; + } + + $reply = mysqli_fetch_assoc($result); + + if (empty($reply)) { + return 'Invalid quote!'; + } + + $id = $id + 1; + + return '
Quote from ' . $reply['user_name'] . ''; + } +} + class Post { public $id; public $content; @@ -36,14 +58,15 @@ class Post { mysqli_free_result($result); } - function display_content() { - echo '
' . $reply['post_content'] . '
' . $post_content . '
'; + echo '' . $post_content . ''; } } -- cgit v1.2.3