0
<?php  
    $images= $uploading['front_image'];
    $whileimg= explode(",", $images);
    foreach ($whileimg as $key => $image) {
        echo  $uploading["front_image"];          
    }
?>

In database I have my images saved in one column(2,3,4 it depends). now when I want them all to show in web ,Instead of images I get the path of the photos, as are saved in database. thank you

4
  • Hey @newuser - I have edited your question to improve the formatting of the code and to make it more readable Commented Aug 31, 2017 at 19:33
  • You need to make it an image take and echo the path in the img tag Commented Aug 31, 2017 at 19:34
  • I tried but didn't worked Commented Aug 31, 2017 at 19:34
  • There is another way to do it, just create a new table and join it. But @clearshot66 have the answer for your case Commented Aug 31, 2017 at 19:35

3 Answers 3

1

To display images, you have use img tag

foreach ($whileimg as $key => $image) {
        echo  "<img src='".$image."' alt='image'>";   
    }
Sign up to request clarification or add additional context in comments.

1 Comment

$whileimg might have only one element. Print it and see elements in it.
1

You need to make it an image take and echo the path in the img is what it sounds like you're getting:

 echo "<img src='".$image."' /> 

instead of

echo  $uploading["front_image"];   

So:

<?php  
    $images= $uploading['front_image'];
    $whileimg= explode(",", $images);
    foreach ($whileimg as $key => $image) {
        echo "<img src='".$image."' />          
    }
?>

1 Comment

Well check your array of images because foreach don't terminate until a break is issued or the array ends
0

Assuming you are fetching comma separated paths of images using the following line:

$images= $uploading['front_image'];

You just need to use the following loop after creating array of paths:

foreach ($whileimg as $key => $image) {
    echo "<img src='$image'>";
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.