...

View Full Version : PHP Dynamic link for next button



reach100
08-11-2008, 10:17 PM
Hi There, I am trying to figure out how to link my photos so that the entire photo can be used as a next button. Currently, the page id controls which image is viewed. I need this new link to basically echo the current id + 1...
In other words if ?id=A1 I would like the link to bring up ?id=A2.

<a href="adventure.php?id=<?php echo $id; ?>">

How can I adjust the syntax to make that happen. How do I limit it at ?id=A26 andhave this link go back to ?id=A1?

Thanks,
Rich V

binaryWeapon
08-12-2008, 01:23 AM
$id=$_GET["id"];
preg_match('{(\d+)}', $id, $m);
$id = $m[1];
$id+=1;$id="A$id";if($id=="A27"){$id="A1";}

Is there any reason you need the "A" in it? Or did you want it to go to B at some point? It doesn't seem to be doing anything so, you could easily use just a number and eliminate the need for a regular expression to extract the number. Then it would be as simple as:


$id=$_GET["id"];$id+=1;if($id=="27"){$id="1";}

reach100
08-12-2008, 01:58 AM
Thanks...
That worked great...
Rich

reach100
08-12-2008, 02:05 AM
How can I get it to skip id?=A15?
Thanks for your help...
Rich V

binaryWeapon
08-12-2008, 02:23 AM
$id=$_GET["id"];
preg_match('{(\d+)}', $id, $m);
$id = $m[1];
$id+=1;$id="A$id";if($id=="A27"){$id="A1";}
if($id=="A15"){$id="A16";}

Glad to help :)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum