Click to See Complete Forum and Search --> : Showing Link as page number


saud
02-19-2007, 02:27 AM
I have a website catalogue and the page numbers are as follows

index.php?page=catalogue_page_01
index.php?page=catalogue_page_02
index.php?page=catalogue_page_03 and so on

Is it possible to display the page number in php pages, like if the user is on page /index.php?page=catalogue_page_05 then I can show "PAGE 5" anywhere on the page. Is it possible.

Please help.

saud
02-19-2007, 02:28 AM
Here is my website
http://www.virginmaryexports.com/index.php?page=catalogue_page_01

NogDog
02-19-2007, 02:33 AM
if(isset($_GET['page']))
{
printf('PAGE %d', (int) preg_replace('/\D/', '', $_GET['page']));
}

saud
02-19-2007, 05:14 AM
Thank you very much for your quick reply. It worked. Thanks again.

I have one more question, can I get automatic Next and Previous link ? As you can see in the bottom of my catalogue page I have included Next and previous buttons. Can I make it automatic. Like if the user is on page five, the link previous link should be <a href="index.php?page=catalogue_page_04">

Thanks again

saud
02-19-2007, 06:13 PM
?????????

saud
02-19-2007, 06:24 PM
My this code is not working

<?
if(isset($_GET['page']))
$next= 1 + $_GET['page'];
$previous= 1 - $_GET['page'];
{
echo"$next";
echo"$previous";
}
?>

NogDog
02-19-2007, 07:51 PM
<p style='text-align: center;'>
<?php
$lastPage = 10;
if(isset($_GET['page']))
{
$thisPage = (int) preg_replace('/\D/', '', $_GET['page']);
$previousPage = ($thisPage > 1) ? $thisPage - 1 : null;
$nextPage = ($thisPage < $lastPage) ? $thisPage + 1 : null;
if($thisPage > 0)
{
if($previousPage)
{
printf('[<a href="index.php?page=catalogue_page_%02d">Previous</a>] ',$previousPage);
}
echo "PAGE $thisPage";
if($nextPage)
{
printf(' [<a href="index.php?page=catalogue_page_%02d">Next</a>] ',$nextPage);
}
}
}
?>
</p>

saud
02-20-2007, 01:50 AM
Thanks for the code. I inserted the code in my website.