I'm trying to print img paths from db in a while to print them all, but it's only printing the first one.
if ($stmt = $mysqli->prepare(" SELECT *
FROM user_uploads
WHERE userID = ?
LIMIT 1")) {
$stmt->bind_param('i', $_SESSION['user_id']);
$stmt->execute();
$result = $stmt->get_result();
while ($row = $result->fetch_array()) {
if (!empty($row['description'])) {
$desc = $row['description'];
} else {
$desc = 'Descripción de la imagen';
}
echo '
<div id="form-main">
<form class="form" action="" method="post" name="image">
<img src="/images/user_uploads/' . $row['image_path'] . '" alt="' . $row['image_name'] . '" height="600" width="600">
<p class="text">
<input name="name" type="text" class="validate[required,custom[onlyLetter],length[0,100]] feedback-input image" id="image" placeholder="' . $row['image_name'] . '"/>
</p>
<div class="submit">
<input type="submit" value="Cambiar nombre" id="button-blue"/>
<div class="ease"></div>
</div><br><br><br><br>
</form>
<form class="form" action="" method="post" name="image">
<p class="text">
<textarea name="text" type="text" class="validate[required,length[6,300]] feedback-input comment" id="comment" placeholder="' . $desc . '"></textarea>
</p>
<div class="submit">
<input type="submit" value="Cambiar descripción" id="button-blue"/>
<div class="ease"></div>
</div>
</form>
</div>';
}
}
In my testing, I have 4 image paths saved in the table. I don't see what's wrong.
Thanks in advance!
LIMIT 9999999999;) or just remove theLIMIT 1altogether.