Note that there are some explanatory texts on larger screens.

plurals
  1. POAdd Ellipsis in PHP Pagination
    primarykey
    data
    text
    <pre><code>. //Prev . for($number = 1; $number &lt;= $num_pages; $number++) { if($page == $number) { $navigator .= "&lt;b&gt;[$number]&lt;/b&gt; "; } else { $navigator .= "&lt;a href='?c=".$_SESSION['cID']".&amp;rows=".$per_page."&amp;page=$number'&gt;$number&lt;/a&gt; "; } } . //Next . </code></pre> <p>This is the snippet that prints number of pages.</p> <p><em>Sample output:</em></p> <p>Previous 1 2 3 4 <strong>[5]</strong> 6 7 8 9 10 Next</p> <p>5 is the current page.</p> <p><strong>Problem:</strong> page numbers are shown in sequence with no restrictions. If i have 100 pages, all numbers show up.</p> <p><strong>Question:</strong> I need my paging numbers appear as the following...</p> <p><strong>Assume we only have 7 ($num_pages) pages:</strong></p> <p>Previous 1 2 <strong>[3]</strong> 4 5 6 7 Next</p> <p><em><strong>Assume we have 90 pages:</em></strong></p> <p><strong>[1]</strong> 2 3 4 5 6 7 ... 90 Next</p> <p><em><strong>Assume user clicked the 7th page:</em></strong></p> <p>Previous 1 ... 5 6 <strong>[7]</strong> 8 9 10 11 ... 90 Next</p> <p><em><strong>Assume user clicked 11th page:</em></strong></p> <p>Previous 1 ... 9 10 <strong>[11]</strong> 12 13 14 15 ... 90 Next</p> <p><em><strong>Assume user clicked 15th page:</em></strong></p> <p>Previous 1 ... 13 14 <strong>[15]</strong> 16 17 18 19 ... 90 Next</p> <p><em><strong>Assume user clicked 90th page:</em></strong></p> <p>Previous 1 ... 84 85 86 87 88 89 <strong>[90]</strong></p> <p><em>Any help will be appreciated.</em></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload