duanfen1312 2013-01-18 11:31
浏览 23

如何在分页控件中结合PHP和jQuery

I am trying to implement paging in PHP. First of all I am getting the number of pages as per page record and generating <li> links dynamically by number of pages. Like this:

for($i = 1; $i <= $no_of_pages; $i++)
{
    echo '<li><a href="view_records.php?pageno='.$i.'">'.$i.'</a></li>';
}

It's fine, but the problem is that when the number of pages is more than 10, the page number wraps to the next line. I want to scroll them by clicking left and right 10 pages each time.

Suppose I have 35 pages, so this will display all 35 pages links

left 1 2 3 4 5 6 7 8 9 10 11 12 ......35 right

But I want only

left 1 2 3 4 5 6 7 8 9 10 right 

When I click on right this will scroll right and should display

left 11 12 13 14 15 17 18 19 20 right

Again right will display next 10 pages link. Is there anything in JS or jQuery to control that li for scrolling? It will be become easy because I get total no of pages by PHP and put link of them in HTML and user can directly move to desired page.

  • 写回答

1条回答 默认 最新

  • dongzong8110 2013-12-12 10:45
    关注

    It's too late for the answer. Anyway, you can initially get the first 10 page links in the page right. Then you can use jQuery to change content inside parent element of li tags (its ul). When you click on 'right', empty the content of ul element. Append new li elements using a loop to generate. You may need a hidden value to control the page limits.

    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度