php mysql 分页输出,使用Mysql和PHP进行分页

I am trying to create a pagination with just next and previous links instead of 1,2,3..etc.

So I have say item 1,2,3,4,5 in the database and each item is on one page.

If I am on item 2 page I would like a previous link for item 1 page and a next link for item 3 page...etc

So far I got up to retrieving all the items in the database and created a loop to spit out all the URL in each item. But I don't quite know the best way to strip off all the items except the adjacent items. This is the loop I have so far.

foreach ($item_url as $url) :

echo $url['url'];

endforeach;

This spits out all URL...But how do i proceed to list only the adjacent items and not count the current item I am on...I tried using next($url); to move the pointer if it matches the current item but it didn't work...

Thanks, guys!

解决方案

Here's a neat resource for paging tabular data without the headache of writing your own code or the need for any PHP at all. Throw all the results into a table (or output them via JSON if you are so inclined) Now, apply the DataTables plugin to the table id and tell it to do pagination. Voila, instant pagination, no brain damage required.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值