PHP & MySQL: fetch images from database

后端 未结 8 919
夕颜
夕颜 2021-02-08 13:06

I have uploaded multiple images and path of all the images have been stored together.

Using explode I have separated them and now I wish to echo them in a c

8条回答
  •  猫巷女王i
    2021-02-08 13:48

    There could be a few problems here...

    1. explode()

    First, your explode() may not work if your $row1["offimage"] string doesn't have asterisks * between the file names. In a reply comment to the OP you've given us an example of the contents of $row1["offimage"], which does NOT separate each PNG file by an asterisk *:

    @lolka_bolka i get this outout, uploads/c376437e2a45598b2f4d89eae4f191e8.pnguploads/c376437e2a45598b2f4d89eae4f‌​191e8.png8069756be5095978123ae51fadbffe3b.pnguploads/c376437e2a45598b2f4d89eae4f‌​191e8.png8069756be5095978123ae51fadbffe3b.png04aaa414c21dc057bc594b896124068e.png 
    –  user3732711 Dec 16 '14 at 12:24 
    

    For your script to work as you've written it, we would expect to see, for example, your $row1["offimage"] string looking like this, with an asterisk * separating each PNG file name (with it's directory path):

     uploads/c376437e2a45598b2f4d89eae4f191e8.png*uploads/c376437e2a45598b2f4d89eae4f‌​191e8.png*8069756be5095978123ae51fadbffe3b.png
    

    2. DIV class 'item'

    As "Dan Soap" & "Rohit the developer" have answered here, for carousel to work, you need to make sure each image is wrapped in its own item class.

    Your code above has echo"

    "; before the while loop.

    echo"

    "; should be INSIDE the while loop - more specifically it should be inside your foreach loop - so that each image in the carousel is wrapped with the item class.

    And don't forget, the item or image you wish to have shown first (on load) should have active class too, as well as the item class, as such:

    .

    3. JavaScript

    You haven't included any JavaScript for us to look at... without calling the carousel() function, nothing will happen, only one (static) image will show. You may need something like this:

    
    

    Hopefully one / some / all of these can help get your carousel up and running! :)

提交回复
热议问题