Forum Moderators: coopster

Message Too Old, No Replies

Increase number by +1 on link click

How to increase a number by +1 and put it as $_GET?

         

alex95_bg

9:42 pm on Mar 16, 2008 (gmt 0)

10+ Year Member



Hello, i have a image gallery script(a very simple one) that takes the contents from the address and puts them like this:
 <img src='$image' border='0' alt='$alt'> 

I have named the images from 1 to 74 and my Apache doesn't require an extension, but i need to put a "Next image" link without hard-coding the addresses.My URL looks like this :
 image.php?image=9&alt=optional alt text 
or
 image.php?image=9.jpg&alt=optional alt text 
.Can i put the alt text somehow?
Please help!
All of my posts seem quite confusing :)

alex95_bg

9:44 pm on Mar 16, 2008 (gmt 0)

10+ Year Member



I was thinking about something like this:
get the $image variable and somehow put +1 more and refresh it...

$image = $_GET['image'];

Habtom

4:26 am on Mar 17, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You could do something like the following:

// for the url image.php?image=9
$image_n = $_GET['image'];
$image_n++;
echo "<a href=\"$image_n\"> Next Image </a>";

// for the url image.php?image=9.jpg
$image_x = explode(".",$_GET['image']);
$image_n = $image_x[0];
$image_n++;
$image_n = $image_n.".".$image_x[0];
echo "<a href=\"$image_n\"> Next Image </a>";

alex95_bg

6:12 pm on Mar 18, 2008 (gmt 0)

10+ Year Member



Thank you very much for this code.It works great.Also i did this:

$image_n = $_GET['image'];
$image_n++;
$image_n_i="?image=$image_n";
echo "<font style='font-family: $fontface; font-size: 10pt;'><a href=\"$image_n_i\">Next image</a>";

I defined image_n_i to add the GET request and the font style tags because i define my font at the beginning of the script.

alex95_bg

6:15 pm on Mar 18, 2008 (gmt 0)

10+ Year Member



And by modifying it a bit i did the previous image link.

$image_n--;