Jump to content

Help with a script which loads next item


ryanwood4

Recommended Posts

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.

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 :P

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.