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.
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.