<?php include "sidebar.php"; ?> <!--Body Goes Here--> <main class="mdl-layout__content"> <div class="bContent" style="text-align:left;"> <!-- InstanceBeginEditable name="Body Content" --> <?php if (isset($_GET['postID'])) { $postID = $_GET['postID']; $post = getPost($mysqli, $postID); if ($post != '') { echo "<h2>" . $post['title'] . "</h2>\n\t\t\t\t\t<h5>" . $post['question'] . "</h5>\n\t\t\t\t\tPosted by: " . $post['author'] . "<br />"; $replies = getReplies($mysqli, $postID); if ($replies == 0) { echo "<h5>There are no replies, be the first!</h5>"; } else { echo "<div class='post'>\n\t\t\t\t\t\t\t<table style='width: 80%; margin-left: 10px;'>"; for ($i = 0; $i < count($replies); $i++) { echo "<tr>\n\t\t\t\t\t \t\t\t<h5>" . $replies[$i]['author'] . "</h5>" . $replies[$i]['title'] . "<br />" . $replies[$i]['reply'] . "</tr>"; } echo "</table>\n\t\t\t\t\t\t</div>"; } } echo "<form action='PHP/new_reply.php?postID=" . $postID . "' method='post' name='reply_form'>\n \n\t\t\t\t\t <h3>Title:</h3>\n\t\t\t\t\t <input name='replyTitle' type='text' size='50' />\n\t\t\t\t\t <br />\n\t\t\t\t\t <br />\n\t\t\t\t\t <h3>Body:</h3>\n\t\t\t\t\t <textarea name='replyText' cols='55' rows='5'></textarea>\n\t\t\t\t\t \n\t\t\t\t\t <input type='submit' value='Submit' />\n\t\t\t\t\t \n\t\t\t\t\t </form>"; } ?> <!-- InstanceEndEditable --> </div>
function updateReplies($mysqli, $post) { $replies = count(getReplies($mysqli, $post)); if ($stmt = $mysqli->prepare("UPDATE `forum_posts` SET `replies`=? WHERE `id`=?")) { // Bind "$id" to parameter. $stmt->bind_param('ii', $replies, $post); $stmt->execute(); // Execute the prepared query. } }