duanlanzhi5509 2012-06-06 04:36
浏览 46
已采纳

PHP - 我如何显示前20个li然后有一个链接显示更多(图库)[关闭]

I want to display about 20 li on a page with a link at the bottom that says something like 'display more'. This link will then clear the first 20 and display the next 20. How should i go about doing this. (I am creating a gallery)

I was thinking about using PHP and MySQL. However for what I am doing I do not really need to store it in a database so is there an easier way of doing it only using html, php or javascript?

thanks

  • 写回答

4条回答 默认 最新

  • dstt1818 2012-06-06 05:37
    关注

    Try this

     $list_images=glob('imagesPath'.'*.{jpg|jpeg|png|gif}', GLOB_BRACE);
    
     if(isset($_REQUEST['page_id']))
     {
         $pageNo=$_REQUEST['page_id'];
     }    
     if($pageNo =='') 
         $offset=0;
     else
          $offset=$pageNo; 
    
     for($i=$offset; $i<($offset+20); $i++)
     {
          echo"<a href=''><img src='$list_images[$i]' /> </a>";
     }
    

    // Store the page no in a hidden variable

     <input type='submit' value='More' onclick ='pageSet()' />
    

    //Javascript

       function pageSet()
       { 
        var id=document.getElementById('page_id').value;
    
         if(id =='')
         { 
              document.getElementById('page_id').value =1;
         }
         else
         {
                document.getElementById('page_id').value =parseInt(id)+1;
         }   
    
      }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题