I have 5 images named 1.png, 2.png, 3.png, 4c.png, & 5.png.
I want to show this images in PHP like this but it shows like this.
My code is:-
<div class="row">
<?php
$images = "/downloads/vf/images/";
for ($i = 1; $i <= 5; $i++):
if (!file_exists($_SERVER['DOCUMENT_ROOT'].$images.$i.".png"))
continue; // Skip this iteration if it can't find the file
?>
<div class="col-md-2">
<div class="thumbnail">
<a href="<?php echo $details . $i;?>.php">
<img src="<?php echo $images;?><?php echo $i;?>.png" alt="<?php echo $i;?>">
</a>
</div>
</div>
<?php endfor; ?>
<?php
$images = "/downloads/vf/images/";
for ($i = 1; $i <= 5; $i++):
if (!file_exists($_SERVER['DOCUMENT_ROOT'].$images.$i."c.png"))
continue; // Skip this iteration if it can't find the file
?>
<div class="col-md-2">
<div class="thumbnail">
<a href="<?php echo $details . $i;?>.php">
<img src="<?php echo $images;?><?php echo $i;?>c.png" alt="<?php echo $i;?>">
</a>
</div>
</div>
<?php endfor; ?>
</div>
Can it be changed in if, elseif.
Aucun commentaire:
Enregistrer un commentaire