This repository has been archived on 2025-12-28. You can view files and clone it, but cannot push or open issues or pull requests.
inkletblot-com-v1/php gallery/index.php
2019-12-02 12:10:45 +10:30

83 lines
1.6 KiB
PHP

<?php
include 'connect.php';
include 'head.php';
$result=$conn->query("SELECT MAX(uploadNo) AS 'max' FROM uploads");
$maxid=intval($result->fetch_assoc()['max']);
$x= 1;
if($maxid == 1) {
echo '<p id="placeholder">Be the first to submit an image!</p>';
}
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 '<div id="apost">
<h2>' . htmlentities($post["uploadName"], ENT_QUOTES | ENT_HTML5, 'UTF-8') . '</h2>
<img src="' . $post["uploadDir"] . '"><br>
<form action="comment_send.php" method="post" enctype="multipart/form-data">
<input type="text" value="comment" name="comment" id="comment">
<input type="text" value="name" name="name" id="name">
<input type="hidden" name="id" value="' . htmlentities($uploadNo, ENT_QUOTES | ENT_HTML5, 'UTF-8') . '" id="id">
<input type="submit" name="submit" value="Submit">
</form>';
echo "<div id'acomment'>";
$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 '<p id="acomment">' . htmlentities($comment['commentText'], ENT_QUOTES | ENT_HTML5, 'UTF-8') . ' - <i>' . htmlentities($comment['commentName'], ENT_QUOTES | ENT_HTML5, 'UTF-8') . '</i></p>';
}
echo "</div>";
echo '</div>';
}
}
include 'foot.php';
?>