how to make image slider into while loop

后端 未结 2 829
不思量自难忘°
不思量自难忘° 2021-01-28 09:46

I have a website retrieving images from database. The database has multiple records (ROWS). I am using while loop to retrieve the records. Every record having three or four imag

2条回答
  •  感情败类
    2021-01-28 10:27

    as per my understanding, it seems you're looking for this kind of solution. Use of js "jquery.bxslider.js", required css "jquery.bxslider.css"

    //assuming this is your database retrieval
    $slideImage[]   = "clody.jpg";
    $slideImage[]   = "heaven.jpg";
    $slideImage[]   = "park.jpg";
    $slideImage[]   = "pool.jpg";
    $slideImage[]   = "provence.jpg";
    
    $slideStr       = "";
    //utlize while loop if required
    foreach($slideImage as $indKey=>$indSlideImg) {
        $slideStr .= '
    '; }

    here in the above loop we created a sliding string, which we are going to utilize that into our slider.

    here comes the javascript

    $(document).ready(function(){
      $('.slider1').bxSlider({
        slideWidth: 200,
        minSlides: 2,
        maxSlides: 3,
        slideMargin: 10
      });
    });
    

    hope it is helpful.

提交回复
热议问题