问题描述
好吧,我正在使用PHP显示动态画廊...我要的是代替在一页上显示很多缩略图,而宁愿进行分页..您知道数字页以及下一页以及全部..
well i am displaying a dynamic gallery using PHP... what i want is to instead of showing a lot of thumbnails on one page i rather do paging.. you know the number pages and next and all..
这是一件老事了,但我不知道该怎么做.
well its an old thing but i don't know how to do this..
- 如何做?
但抱住马匹扭腰
我在DIVS中显示缩略图,我在行中设置了缩略图,所以可以说如果有人打开1024x768的页面,则我会连续获得3个缩略图,并且有6行,因此它们总共制作了18个缩略图.
i am showing thumbnails in DIVS which i set in line so lets say if someone open the page in 1024x768 i get 3 thumbnails in a row and and there are 6 rows so they make 18 thumnails on the whole..
但是,如果有人打开其分辨率为1600 x 1200的页面,则我连续获得5个缩略图,因此18个缩略图将构成3行..可以说我想保留第6行并将缩略图弹出至30. .. 如何使用代码来做到这一点
but if someone open the page with their resolution lets say 1600 x 1200 i get 5 thumnails in a row so 18 thumbnails would make 3 rows.. lets say i want to keep the rows 6 and pop up the thumbnails to 30... HOW TO RIDE A CODE TO DO THAT
p.s.祝我疯狂的唐卡好运....
p.s. best of luck with my crazy thangs....
推荐答案
基本技术是这样的:您知道或计算每页显示多少图像.因此,当您进行查询时,这就是您的LIMIT.另外,您将需要一个偏移量-您需要跳过多少个结果.如果您每页显示8个结果,并且要显示第3页,则偏移量将为(3-1)* 8或16.
The basic technique is this: You know, or else calculate, how many images you're displaying per page. So when you do your query, that's your LIMIT. Also, you're going to need an offset - how many results you need to skip over. If you were showing 8 results per page and you wanted to show the 3rd page, your offset would be (3 - 1) * 8, or 16.
现在,您的有趣挑战听起来像是显示屏:您将根据显示屏显示不同数量的缩略图.因此,您可能需要使用javascript来计算所需的显示大小,然后基于显示的页面发出ajax请求以查询所需的结果量和偏移量.
Now, your interesting challenge sounds like your display: You're showing different amounts of thumbnails based on the display. So you will need to calculate how big of a display you want, probably with javascript, and then make an ajax request to query for the amount of results you want and the offset, based on the page you're showing.
这篇关于PHP动态画廊分页(略有不同)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!