Jssor for jssor slider user is it possible to make

2019-07-18 02:37发布

I have made a jssor slider in my project it is working perfectly. I have decide to add database to my project and i want to save image address to database so i can i just add images to slider.

1.My question is it possible to dynamic images to jssor slider?

2.What i want is from database i will get all images and i will do a foreach to show images

this is how i do the code

<div u="slides" style="cursor: move; position: absolute; left: 0px; top: 0px; width: 720px; height: 480px;
            overflow: hidden;">
            <?php
                foreach (LoadImageGallery() as $value){
                    echo $value['searchresultbigimg'];
                    echo "<li><img src=\"admin/".$value['searchresultbigimg']."\"></li>";
                    echo $value['searchresultthumbnailimg'];
                    echo "<li><img src=\"admin/".$value['searchresultthumbnailimg']."\"></li>";
                }
            ?>

        </div>

UPDATE

i get this error when i tried your solution sir jssor this is what i tried Slides html code definition error, there must be at least 1 slide to initialize a slider.

<div u="slides" style="cursor: move; position: absolute; left: 0px; top: 0px; width: 600px; height: 300px; overflow: hidden;">

            <?php
                foreach (LoadImageGallery() as $value){
                    echo $value['searchresultbigimg'];
                    echo "<div><img src=\"admin/".$value['searchresultbigimg']."\"></div>";
                    echo $value['searchresultthumbnailimg'];
                    echo "<div><img src=\"admin/".$value['searchresultthumbnailimg']."\"></div>";
                }
            ?>

        </div>

2条回答
我欲成王,谁敢阻挡
2楼-- · 2019-07-18 02:52

I think you want something like this. I found the basic code for the array here http://www.the-art-of-web.com/php/directory-list-spl/

 <?php
          // filetypes to display  
          $imagetypes = array("image/jpeg", "image/jpg", "image/png"); 
          function getImageList($dir) 
          { 
            global $imagetypes;
            // array to hold return value 
            $imagefiles = array(); 
            // add trailing slash if missing 
            if(substr($dir, -1) != "/") $dir = "images"; 
            // open directory for reading 
            $d = new DirectoryIterator($dir) or die("getImageList: Failed opening directory $dir for reading"); 
            foreach($d as $fileinfo) { 
              // skip hidden files 
              if($fileinfo->isDot()) continue;
              $imagefiles[] = array( 
                'file' => "{$dir}{$fileinfo}" 
              ); 
            } 
            shuffle($imagefiles);   
            return $imagefiles;
          } 
        ?>
             <div id="slider1_container" style="position: relative; margin: 0 auto; top: 0px; left: 0px; width: 1000px; height: 800px;">
                 <div data-u="slides" style="cursor: move; position: absolute; left: 60px; top: 0px; width: 1000px; height: 800px; overflow: hidden;">
       <?php 
           // fetch image details 
          $images = getImageList("images/"); 
           // generate list for slideshow 
          foreach($images as $img) {
          $path = ("{$img['file']}");                   
           // display on page 
echo <<<JSDIVS

              <div>
                  <div><img data-u="image" src2="$path" style="position: relative; display: block; bottom:0;"/></div>
              </div>   

JSDIVS;
}
       ?>
                 </div>            
             </div>
查看更多
可以哭但决不认输i
3楼-- · 2019-07-18 03:06

Yes, you can and you are on your way.

But you should use 'DIV' instead of 'LI'.

Jssor Slider slide html code is as below,

<div><img u="image" src="image.jpg" /></div>

Reference http://www.jssor.com/development/define-slides-html-code.html

查看更多
登录 后发表回答