...

View Full Version : next page link



GO ILLINI
01-10-2006, 11:16 PM
I have pages, 1.php, 2.php, 3.php and so on. I would like to make a next page and last page links at the bottom of each of them. Is there a way to get the pagename then take the .php off of it, and then add or subtract 1 and then echo that?


$nextpage = "(php_self - .php + 1)";
$lastpage = "(php_self - .php - 1)";
I know that is not even close, but use that idea.


Thanks,
ILLINI

ralph l mayo
01-10-2006, 11:34 PM
$thisnum = (int) pathinfo($_SERVER['PHP_SELF'], PATHINFO_BASENAME); // to use th cast method, the number must be the FIRST thing in the filename
$prev = ($thisnum > 1) ? $thisnum - 1 : false; // don't go below one
$next = (file_exists($thisnum + 1 . '.php')) ? $thisnum + 1 : false; // check if the next higher number exists... alternatively, you can just check against a static max here

if ($prev)
{
echo '<a href="' . $prev . '.php">Previous</a>';
}
if ($next)
{
echo '<a href="' . $next . '.php">Next</a>';
}

GO ILLINI
01-16-2006, 07:54 AM
THank you, That worked.
But I have a problem. I changed my page structure. Now I have ?type=html?p={number here now}
Could you please try to do the same thing only with my new links?
Thanks,
ILLINI



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum