使用 PHP 在多个页面上显示内容
在我的一款 Facebook 应用程序中,我想添加一项功能,让用户能够查看发送给他们的礼物,即使他们已经接受了礼物。问题是,如果将它们全部显示在一个页面上,页面就会太长。我如何才能每页显示最多 8 张图像。问题是,我不知道如何创建第二个、第三个等页面来显示。
我想要的就像一个搜索引擎。显示这么多,然后进入下一页。
In one of my Facebook Apps, I want to add the ability for the user to view the gifts that were sent to them, even after they have accepted them. The problem is, the page would be entirley too long if they were all displayed on one. How would I go about displaying up to 8 images per page. The probelm is, I don't know exactly how the second, third, etc pages are created to display.
What I want is just like a search engine. Display so many, then go to the next page.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您在某个数据库中拥有他们发送的礼物,对吧?
一次从该表中
SELECT
8 行。使用 LIMIT 子句指定您需要 8 行,以及从哪一行开始选择这 8 行。http://dev.mysql.com/doc/refman/5.1/en/select.html
偏移量是页码,减1,乘以8例如
第 3 页:
You have the gifts they were sent in some database, right?
SELECT
from that table 8 rows at a time. Use aLIMIT
clause to specify that you want 8 rows, and from which row to start picking those 8.http://dev.mysql.com/doc/refman/5.1/en/select.html
The offset is the page number, minus 1, multiplied by 8.
Ex for page 3:
使用页面标识符来检测页码。页码应为 0,1,2,3..
然后将其乘以每页的结果数,以获得接下来 8 个结果的起始行。
例如,当前页面有一个名为 pageNumber 的变量。
用于获取起始行的 limit 变量。
那么查询将是
“现在”,如果页码为 0,则限制将为 0,如果页码为 1,则限制将为 8,反之亦然。
Use a page identifier to detect page number. The page number should be 0,1,2,3..
Then multiply it with number of results per page to get starting row from where you want next 8 results.
For example you have a variable called pageNumber for current page .
A limit variable to get starting row.
Then the query will be
Now if your page number is 0 then limit will be 0 and if page number is 1 then limit will be 8 vice verse..