Reputation: 1699
Here's my code :
<div id="slides" class="col-md-7" >
<img src="'.$row['img2'].'" >
</div>
In that "img2" row in the database, it's image path. But I need to detect if there's more than one image path seperated by a comma in there.
So if there's 2 images in the field (ex.: img/image1.jpg, img/image2.jpg), well the HTML would look like :
<div id="slides" class="col-md-7" >
<img src="'.$row['img2(first value)'].'" >
<img src="'.$row['img2(second value)'].'" >
</div>
But if there's only 1 value, it stays like my first code part. Anyone? Thanks a lot
Upvotes: 1
Views: 54
Reputation: 1140
use the explode function and then a foreach loop
<div id="slides" class="col-md-7" >
<?php
$images = explode(',', $row['img2']);
foreach($images as $image) {
?>
<img src="<?php echo $image; ?>" >
<?php } ?>
</div>
Upvotes: 1