I already have multiple-image upload which allows to upload maximum 5 images to a bootstrap card. I'm trying to add an image update page to my website where users can delete/update their images separately, one by one. The problem is, I don't know how to set the maximum limit here, because there are people who have 2 images uploaded, so they need 3 more input fields. But if someone has 0 image in the database, he needs 5 more input fields to upload the images. I'm stuck, because I don't know how to show the input fields, depends on the database.
Here's my code:
<?php
$sql = "SELECT id FROM cardimages WHERE cardid= ?";
$stmt = $conn->prepare($sql);
$id = $_GET['id'];
$stmt->bind_param('i', $id);
$stmt->execute();
$result = $stmt->get_result();
$number = $stmt->num_rows();
echo $number;
if ($stmt->num_rows() > 0){
while ($row = $result->fetch_assoc()) {
$data[] = $row;
$number = $stmt->num_rows();
echo $number;
?>
<img src="imageView.php?id=<?php echo $row["id"]; ?>" class="img-fluid" alt="" style="width: 30%; margin-bottom: 10px;"/>
<button type="submit" class="btn btn-primary btn-xl">Módosítás</button>
<button type="submit" class="btn btn-danger btn-xl" style="background-color: red;">Törlés</button>
<?php
} // while
} else {
echo '<h5>Nincs megjelenítendo kép.</h5>';
} //if
?>
<input type="file" name="uploaded_file[]" id="file" >
<input type="file" name="uploaded_file[]" id="file" >
<input type="file" name="uploaded_file[]" id="file" >
<input type="file" name="uploaded_file[]" id="file" >
<input type="file" name="uploaded_file[]" id="file" >
it allows them to upload 5 more images, but there are 2 images already exists in the database. How can I disable or hide the input fields in SERVER side, depends on the database values?