NoBody NoBody - 1 month ago 14
PHP Question

How to display images from image path save in DB

I'm trying to display images in foreach loop but its not working. I dont know what is wrong with my code. I hope someone could help me. Below is my code

<div class="container">
<div class="row">
<div class="col-md-12">
<div class="row">
<?php foreach ($query as $query): ?>
<div class="col-sm-4 col-lg-4 col-md-4">
<div class="thumbnail">
<img src='".$query['path']."' alt="">
<div class="caption">
<h4 class="pull-right">RM <?= $query['product_price'] ?></h4>
<h4><a href="#"><?= $query['product_name'] ?></a>
</h4>
<p><?= $query['product_desc'] ?></p>
</div>
</div>
</div>
<?php endforeach; ?>
</div>
</div>
</div>



Answer

Change

<img src='".$query['path']."' alt="">

To

<img src='<?= $query['path'] ?>' alt="">
Comments