Qua Sar
03-05-2009, 05:23 AM
Hello,
I have PHP code that loads a picture and based on that pictures and says below it < 1 of 10 > and the arrows let you travel the pictures.
The code for that is:
<?php
// init variables
$pic_num = 1;
$pic_max = 10;
$pic_prefix = 'P';
$pic_format = '.JPG';
if (isset($_GET['number'])) {$pic_num = $_GET['number'];}
// set img links and src
$pic = $pic_prefix.$pic_num.$pic_format;
$pic_back = $pic_num - 1;
$pic_forward = $pic_num + 1;
if ($pic_back < 1) {$pic_back = $pic_max;}
if ($pic_forward > $pic_max) {$pic_forward = 1;}
// display pic and links
?>
<img src="pictures/<?php echo $pic; ?>" WIDTH=300 HEIGHT=250><br>
<a href="<?php echo $_SERVER['PHP_SELF']."?number=".$pic_back; ?>"><</a>
<?php echo $pic_num." of "; echo $pic_max; ?>
<a href="<?php echo $_SERVER['PHP_SELF']."?number=".$pic_forward; ?>">></a>
<php echo $pic; ?>
Now i'm trying to take this PHP code and have the same thing hapen in javascript
I started out alright but i realized i'm not sure how to determine the picture's number which seems to be the way the PHP dtermines what picture to load, what numbers to display below and where to go if you click that pic.
Any help would be appreciated.
I have PHP code that loads a picture and based on that pictures and says below it < 1 of 10 > and the arrows let you travel the pictures.
The code for that is:
<?php
// init variables
$pic_num = 1;
$pic_max = 10;
$pic_prefix = 'P';
$pic_format = '.JPG';
if (isset($_GET['number'])) {$pic_num = $_GET['number'];}
// set img links and src
$pic = $pic_prefix.$pic_num.$pic_format;
$pic_back = $pic_num - 1;
$pic_forward = $pic_num + 1;
if ($pic_back < 1) {$pic_back = $pic_max;}
if ($pic_forward > $pic_max) {$pic_forward = 1;}
// display pic and links
?>
<img src="pictures/<?php echo $pic; ?>" WIDTH=300 HEIGHT=250><br>
<a href="<?php echo $_SERVER['PHP_SELF']."?number=".$pic_back; ?>"><</a>
<?php echo $pic_num." of "; echo $pic_max; ?>
<a href="<?php echo $_SERVER['PHP_SELF']."?number=".$pic_forward; ?>">></a>
<php echo $pic; ?>
Now i'm trying to take this PHP code and have the same thing hapen in javascript
I started out alright but i realized i'm not sure how to determine the picture's number which seems to be the way the PHP dtermines what picture to load, what numbers to display below and where to go if you click that pic.
Any help would be appreciated.