/    Sign up×
Community /Pin to ProfileBookmark

Showing Link as page number

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.

to post a comment
PHP

7 Comments(s)

Copy linkTweet thisAlerts:
@NogDogFeb 19.2007 — [code=php]
if(isset($_GET['page']))
{
printf('PAGE %d', (int) preg_replace('/D/', '', $_GET['page']));
}
[/code]
Copy linkTweet thisAlerts:
@saudauthorFeb 19.2007 — 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
Copy linkTweet thisAlerts:
@saudauthorFeb 19.2007 — ?????????
Copy linkTweet thisAlerts:
@saudauthorFeb 19.2007 — My this code is not working

<?

if(isset($_GET['page']))

$next= 1 + $_
GET['page'];

$previous= 1 - $_GET['page'];

{

echo"$next";

echo"$previous";

}

?>
Copy linkTweet thisAlerts:
@NogDogFeb 20.2007 — [code=php]
<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>
[/code]
Copy linkTweet thisAlerts:
@saudauthorFeb 20.2007 — Thanks for the code. I inserted the code in my website.
×

Success!

Help @saud spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...