Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to limit pagination function navigation to 10 per page
    primarykey
    data
    text
    <p>I have a pagination function that I use for my database search that limits the results per page to 25. However, I have roughly 2300 entries and when someone does a search that queries a lot of results I end up with 90 or so pagination links at the bottom of my page. I would like to limit the pagination navigator to only show 10 pages at a time, adjusting accordingly with page spelunking.</p> <p>I'm not quite sure how to adjust my script.</p> <p>Any help would be greatly appreciated.</p> <p>My current function is so:</p> <p>$search_function is a javascript function for getting the proper URL, $classical_guitar is referring to images.</p> <pre><code>function generate_page_links($cur_page, $num_pages) { global $search_function, $classical_guitarL, $classical_guitarR; $page_links = ''; // If this page is not the first page, generate the "previous" link if ($cur_page &gt; 1) { $page_links .= '&lt;a href="javascript:' . $search_function . "('', '" . ($cur_page - 1) . "');\"&gt;" . $classical_guitarL . "&lt;/a&gt; "; } else { $page_links .= ''; } // Loop through the pages generating the page number links for ($i = 1; $i &lt;= $num_pages; $i++) { if ($cur_page == $i) { $page_links .= ' ' . $i; } else { $page_links .= '&lt;a href="javascript:' . $search_function . "('', '" . $i . "');\"&gt; " . $i . "&lt;/a&gt; "; } } // If this page is not the last page, generate the "next" link if ($cur_page &lt; $num_pages) { $page_links .= '&lt;a href="javascript:' . $search_function . "('', '" . ($cur_page + 1) . "');\"&gt;" . $classical_guitarR . "&lt;/a&gt; "; } else { $page_links .= ''; } return $page_links; } </code></pre>
    singulars
    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.
    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