query("SELECT MAX(uploadNo) AS 'max' FROM uploads"); $maxid=intval($result->fetch_assoc()['max']); $x= 1; if($maxid == 1) { echo '

Be the first to submit an image!

'; } else { while($x < $maxid) { $x++; $uploadNo=$x; $sql="SELECT uploadDir, uploadName FROM uploads WHERE uploadNo = ?"; $stmt=$conn->prepare($sql); $stmt->bind_param('i', $x); $stmt->execute(); $post = $stmt->get_result()->fetch_assoc(); echo '

' . htmlentities($post["uploadName"], ENT_QUOTES | ENT_HTML5, 'UTF-8') . '


'; echo "
"; $sql = "SELECT * FROM comments WHERE uploadNo = ?"; $stmt = $conn->prepare($sql); $stmt->bind_param('i', $uploadNo); $stmt->execute(); $comments = $stmt->get_result(); while($comment = $comments->fetch_assoc()) { echo '

' . htmlentities($comment['commentText'], ENT_QUOTES | ENT_HTML5, 'UTF-8') . ' - ' . htmlentities($comment['commentName'], ENT_QUOTES | ENT_HTML5, 'UTF-8') . '

'; } echo "
"; echo '
'; } } include 'foot.php'; ?>