Jump to content

Trouble with Next/Previous links


foucquet

Recommended Posts

I am trying to create a gallery page, one photo on the page with Next/Previous links either above or below but am having a little local difficulty. This is what I have:-

 

//>>> Set up arrays and variables <<<
$piccies = array();
$exif = array();
$exifdata = array();

$pic = 0;
$img ='';
$date = '';
$time = '';
$caption = '';
$copyright ='';
$imageid = 1;
$first = 1;
$last = 5;
$self = $_SERVER['PHP_SELF'] . "?imageid=";

//>>> Read images from folder and assign to the array $piccies[] <<<
$piccies = read_folder();


//>>> Find image and extract the Exif info <<<
$exif = read_exif_info($piccies, $pic);



//>> Populate with required info from $exifdata with required info from $exif
$exifdata = populate_exif_data($exif, $date, $time);

$img = substr_replace($img, "", 0, 2);

?>

<div id="pict">
<img src="<?php echo $img; ?>" />
  <?php
  echo "<p>" . $caption . "</p>";
  if ($imageid < $last) {
    echo "<a href=" . $self . ($imageid + 1) . "><h2>Next</h2></a>";
}
if ($imageid > $first) {
    echo "<a href=" . $self . ($imageid - 1) . "><h2>Previous</h2></a>";
}
  ?>
</div>

 

It puts the 'Next' link in fine, but when clicked the link goes to the Parent directory:-

 

Index of /php/gallery

[iCO] Name Last modified Size Description

[DIR] Parent Directory -

[ ] functions.php 27-Oct-2011 09:25 2.1K

[ ] gallery index.php 27-Oct-2011 09:45 1.8K

[DIR] images/ 26-Oct-2011 16:00 -

 

and when I look at the source I see that the link has not been constructed as I expected. This is the source:-

 

<div id="pict">

<img src="images/blue sky.jpg" />
  <p>Blue Sky over Auld Reekie</p><a href=/php/gallery test.php?imageid=2><h2>Next</h2></a></div>

 

where '/php/gallery test.php' is showing I expected 'images/filename.jpg' etc. and I just can't figureout what I have done wrong...

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.