I am trying to make to display cells in a database that are not empty, i have URL links with images inside the table and i want to display only the cells that are not empty.
For example if there is only 2 pictures added in the database i want to display only those 2, and not the rest 3 with no images
I have this code but its going on forever and its crashing my browser.
<?php
$sql = "SELECT pic1, pic2, pic3, pic4, pic5 FROM modelprofile WHERE name='$name'";
$result = $conn->query($sql);
if($result === false) {
trigger_error('Wrong SQL: ' . $sql . ' Error: ' . $conn->error, E_USER_ERROR);
} else {
while($row = $result->fetch_assoc()) {
$pic1 = $row["pic1"];
$pic2 = $row["pic2"];
$pic3 = $row["pic3"];
$pic4 = $row["pic4"];
$pic5 = $row["pic5"];
while(!empty($row)) {
?>
<img class="card-img-top" src="<?= $pic1 ?>" alt="">
<br><br>
<img class="card-img-top" src="<?= $pic2 ?>" alt="">
<br><br>
<img class="card-img-top" src="<?= $pic3 ?>" alt="">
<br><br>
<img class="card-img-top" src="<?= $pic4 ?>" alt="">
<br><br>
<img class="card-img-top" src="<?= $pic5 ?>" alt="">
<br><br><br>
<?php
}
}
}
?>