A
Anonymous
Guest
Somebody else made this suggestion for limiting results to 15 per page with previous/next links:
I can't find this person anymore so I'll ask those of you who may understand.
I added this to my exisitng code and the first page works fine. All other pages work fine if you type "?page=3" or such in the url. The problem seems to come from the previous / next links generated at the bottom. The previous link always links to the CURRENT page and the next link always links to the PREVIOUS page.
See it here:
http://www.pstvalumni.com/directory/index3.php
Or here in a more simplified way with all ORDER BY complications removed:
http://www.pstvalumni.com/directory/index4.php
I don't understand how the last two lines were created so can anybody help me fix them, please? Or can somebody give me a better solution altogether?
Have a $page variable...
--------------------
if(!isset($page)) { $page = 0; }
$per_page = 15;
$limit = $page * $per_page;
$query = "SELECT * FROM table LIMIT $limit,$per_page";
--------------------
Something like that...For your next link, you pass $page++, for prev, you pass $page--. Need to throw in some extra stuff that checks the limits of the pages, though....
--------------------
echo "<a href='$PHP_SELF?page=" . $page-- . "'>Prev</a>";
echo "<a href='$PHP_SELF?page=" . $page++ . "'>Next</a>";
--------------------
I can't find this person anymore so I'll ask those of you who may understand.
I added this to my exisitng code and the first page works fine. All other pages work fine if you type "?page=3" or such in the url. The problem seems to come from the previous / next links generated at the bottom. The previous link always links to the CURRENT page and the next link always links to the PREVIOUS page.
See it here:
http://www.pstvalumni.com/directory/index3.php
Or here in a more simplified way with all ORDER BY complications removed:
http://www.pstvalumni.com/directory/index4.php
I don't understand how the last two lines were created so can anybody help me fix them, please? Or can somebody give me a better solution altogether?