douxuexiao1748 2010-10-13 18:57
浏览 26

分页与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!

  • 写回答

1条回答 默认 最新

  • dongyi6269 2010-10-13 20:43
    关注

    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.

    评论

报告相同问题?

悬赏问题

  • ¥50 三种调度算法报错 有实例
  • ¥15 关于#python#的问题,请各位专家解答!
  • ¥200 询问:python实现大地主题正反算的程序设计,有偿
  • ¥15 smptlib使用465端口发送邮件失败
  • ¥200 总是报错,能帮助用python实现程序实现高斯正反算吗?有偿
  • ¥15 对于squad数据集的基于bert模型的微调
  • ¥15 为什么我运行这个网络会出现以下报错?CRNN神经网络
  • ¥20 steam下载游戏占用内存
  • ¥15 CST保存项目时失败
  • ¥20 java在应用程序里获取不到扬声器设备