> > Do you want to list all the pages of posts or just a link to the next 20
> > items?
>
> On the first page, 20 and links to the other items that when selected will
> display the list based on the selection.
>
> One thing to remember is that the ids will not be in squence.
Here's a function I wrote to do that. I can't promise that it isn't still
buggy, but it's been working on my forum for a while now.
/*************************************************************************/
/* print nextLinks
* Prints a list of "next page" links for a list of items
* spanning more than one page.
* The links look something like this:
* Page 1 | 2 | 3
* It cycles through the array of IDs supplied by the user
* and prints one every "itemsPerPage" interval
* param idArray - an array of all the id numbers of the thing that the menu
relates to
* param pageURL - the actual url for the pages that are linked
* param itemsPerPage - the number of items per page
* param currentID - the ID of the last item on the current page
*/
function printNextLinks($idArray, $pageURL, $itemsPerPage, $currentID,
$direction) {
// variables
$postCount = count($idArray);
$postPlace = 0;
$iteration = 1;
$threadLinks = "";
$lastID = $idArray[$postCount - 1];
$firstNextPage = $idArray[0];
// we only want the pages link if there is more than one page
if ($postCount > $itemsPerPage && $firstNextPage != '') {
while($postPlace <= $postCount && $firstNextPage != '') {
$thisID = $idArray[$postPlace];
$nextPlace = $postPlace + $itemsPerPage;
$lastCurrentPage = $idArray[$nextPlace - 1];
$firstNextPage = $idArray[$nextPlace];
if($lastCurrentPage == "") {
$lastCurrentPage = $thisID;
} // end if
if(($currentID == $lastCurrentPage) && ($thisID != '') &&
$direction == "desc") {
$threadLinks .= " $iteration |";
} else if (($currentID == $lastID) && ($firstNextPage == '') &&
$direction == "desc") {
$threadLinks .= " $iteration |";
} else if (($currentID == $lastCurrentPage) && ($thisID != ''))
{
$threadLinks .= " $iteration |";
} else if (($currentID == $lastID) && ($firstNextPage == '')) {
$threadLinks .= " $iteration |";
} else {
$threadLinks .= " <A
HREF=\"".$pageURL."ID=$thisID\">$iteration</A> |";
} // end else
// move everything along
$postPlace = $nextPlace;
$iteration ++;
} // end while
// remove the last line from the threadlinks
$threadLinks = subStr($threadLinks, 0, -1);
echo " $threadLinks | ";
} // end if
} // end function
Helen
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]