ryanwood4 Posted January 4, 2010 Share Posted January 4, 2010 I have a script which displays an image, but I now need a script which loads the next image. It simply needs to load a url with an id at the end which is one higher than the current, i.e. Current page: www.example.com/12 Then when you click 'next' it loads www.example.com/13 so it always needs to load +1. Not sure if this makes much sense tbh. Any help is appreciated. Link to comment https://forums.phpfreaks.com/topic/187178-help-with-a-script-which-loads-next-item/ Share on other sites More sharing options...
ryanwood4 Posted January 4, 2010 Author Share Posted January 4, 2010 Ok, I have figured it out, it was very simple. I just echoed the current URL and added +1. Link to comment https://forums.phpfreaks.com/topic/187178-help-with-a-script-which-loads-next-item/#findComment-988423 Share on other sites More sharing options...
monkeypaw201 Posted January 4, 2010 Share Posted January 4, 2010 Sure, thats pretty easy. First, you'll need to retrieve the current number from the URL with something like this; <?php //retrieve current number $currentnumber = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH); // then you redirect header("Location: http://www.mydomain.com/".($currentnumber+1)); ?> The parse_url function is explained here:http://php.net/manual/en/function.parse-url.php EDIT: beat me to it Link to comment https://forums.phpfreaks.com/topic/187178-help-with-a-script-which-loads-next-item/#findComment-988424 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.