"Zombie Commando [raisinlove]" wrote:
>
> Hi,
> Here's a small but efficient feature I want to add in my template generated
> php site.
> I would like to add simple "previous" and "next" links in certain content
> pages.
>
> Since my URLs are generated like so:
>
www.site.com/template.php?content=news ,
> Is it possible to for a script to read the "content" variable and verify if
> there is a number following it?
>
> This way the "next" link in the content file would know that if the URL is
>
www.site.com/template.php?content=news1 , then it will go to:
>
www.site.com/template.php?content=news2 when clicked on.
>
> If
www.site.com/template.php?content=news3 doesnt exist, it would simply go
> back to:
>
www.site.com/template.php?content=news1
>
> Of course, if there is no number in the value of "content", this wont work.
> I would only put the next and prvious links in numbered pages anyway.
>
> Is this clear?
> Can anyone help?
>
> -steph
>
www.raisinlove.com
>
> "Well its simple, AJ. We're cool and you're not. You should just feel lucky
> that we're not pounding your ass by the bike racks after school." - Marian
> Try Slaughter on AJ Razor
>
> rezinluv @ gashed.com
> webmaster @ mutemag.com
> webmaster @ drawnandquarterly.com
$number=substr($content,strlen($content)-1);
This grabs the last character from the string. However, if you have
numbers that are more digits, you could either use a regex type of
statement, or format all the numbers equally. For instance if you think
that you may get to 999 for the back next (doubtful), you could format
all the numbers with 3 digits. Then you'd have news001, news002, etc and
use the above with -3 instead of -1