VIew files in directory with pagination - php

前端 未结 6 1758
遇见更好的自我
遇见更好的自我 2020-12-30 15:06

I want to display files in my directory in browser. I know that this is possible using @opendir and readdir .. But what I want is to limit the numb

6条回答
  •  甜味超标
    2020-12-30 15:53

    Depends on how you want to go about it. There are a ton of javascript/jquery pagination libraries out there .. just google "Javascript pagination."

    If javascript is not an option or if you would prefer to just use php, then it should be relatively simple.

    Use opendir/readdir to get a list of all the files. Set up however many you want for display. Divide the remainder by this number to get the number of pages. Then take a slice from the array of the (page - 1) * (number to list) up to (number to list). These are the files you will show. Pass the page number through get/post. If it's too high, then use the last page, too low or non-numeric, use the first page.

提交回复
热议问题