showing current page number in javascript image slideshow
- tiffix
- Student


- Joined: Jun 03, 2009
- Posts: 65
- Loc: kenya
- Status: Offline
Please help put page number 1 of x at the bottom i've tried using php global $_GET but still fail. thanks
Code: [ Select ]
<?php
ob_start();
session_start();
if(!empty($_SESSION['previouslargephoto1'])){
$img1 = $_SESSION['previouslargephoto1'];
$img1descrip = $_SESSION['proponedescrip'];
$firstimg[] = $img1;
$firstdecrip[] = $img1descrip;
$count[] = 1;
}
if(!empty($_SESSION['previouslargephoto2'])){
$img2 = $_SESSION['previouslargephoto2'];
$img2descrip = $_SESSION['proptwodescrip'];
$firstimg[] = $img2;
$firstdecrip[] = $img2descrip;
}
if(!empty($_SESSION['previouslargephoto3'])){
$img3 = $_SESSION['previouslargephoto3'];
$img3descrip = $_SESSION['propthreedescrip'];
$firstimg[] = $img3;
$firstdecrip[] = $img3descrip;
}
if(!empty($_SESSION['previouslargephoto4'])){
$img4 = $_SESSION['previouslargephoto4'];
$img4descrip = $_SESSION['propfourdescrip'];
$firstimg[] = $img4;
$firstdecrip[] = $img4descrip;
}
if(!empty($_SESSION['previouslargephoto5'])){
$img5 = $_SESSION['previouslargephoto5'];
$img5descrip = $_SESSION['propfivedescrip'];
$firstimg[] = $img5;
$firstdecrip[] = $img5descrip;
}
if(!empty($_SESSION['previouslargephoto6'])){
$img6 = $_SESSION['previouslargephoto6'];
$img6descrip = $_SESSION['propsixdescrip'];
$firstimg[] = $img6;
$firstdecrip[] = $img6descrip;
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Simple Gallery</title>
<script type="text/javascript">
var num=1;
imgArray = [
<?php if(!empty($_SESSION['previouslargephoto1'])){?>['<?php echo $img1;?>', '<?php echo $img1descrip;?>'],<?php }?>
<?php if(!empty($_SESSION['previouslargephoto2'])){?>['<?php echo $img2;?>', '<?php echo $img2descrip;?>'],<?php }?>
<?php if(!empty($_SESSION['previouslargephoto3'])){?>['<?php echo $img3;?>', '<?php echo $img3descrip;?>'],<?php }?>
<?php if(!empty($_SESSION['previouslargephoto4'])){?>['<?php echo $img4;?>', '<?php echo $img4descrip;?>'],<?php }?>
<?php if(!empty($_SESSION['previouslargephoto5'])){?>['<?php echo $img5;?>', '<?php echo $img5descrip;?>'],<?php }?>
<?php if(!empty($_SESSION['previouslargephoto6'])){?>['<?php echo $img6;?>', '<?php echo $img6descrip;?>']<?php }?>
// Note: no comma after last entry
]
function slideshow(slide_num) {
document.getElementById('mypic').src=imgArray[slide_num][0];
document.getElementById('mypic').alt=imgArray[slide_num][1];
document.getElementById('burns').innerHTML=imgArray[slide_num][1];
}
function slideshowUp() {
num++;
num = num % imgArray.length;
slideshow(num);
}
function slideshowBack() {
num--; if (num < 0) {num=imgArray.length-1;}
num = num % imgArray.length;
slideshow(num);
// location.href="example.php?num=" + num;
}
</script>
</head>
<body onLoad="slideshow(0)">
<div style="text-align: center">
<!-- Place the first image here -->
<?php
$img1 = $firstimg[0];
$img1descrip = $firstdecrip[0];
$ttimages = count($firstimg,0);
/*if(isset($_GET['num'])){
echo $num=$_GET['num'];
}
if(!isset($_GET['num'])){
echo $num=1;
}*/
?>
<img id='mypic' src="<?php echo $img1;?>" name='mypic' border="0" height="150" width="200">
<br>
<!-- Place the text for the first image here -->
<div id="burns"><?php echo $img1descrip;?></div>
<p>
<a href="#" onClick="slideshowBack(); return false;">« Previous</a> 1 of <?php echo $ttimages;?> <a href="#" onClick="slideshowUp(); return false;"> Next »</a>
</div>
</body>
</html>
ob_start();
session_start();
if(!empty($_SESSION['previouslargephoto1'])){
$img1 = $_SESSION['previouslargephoto1'];
$img1descrip = $_SESSION['proponedescrip'];
$firstimg[] = $img1;
$firstdecrip[] = $img1descrip;
$count[] = 1;
}
if(!empty($_SESSION['previouslargephoto2'])){
$img2 = $_SESSION['previouslargephoto2'];
$img2descrip = $_SESSION['proptwodescrip'];
$firstimg[] = $img2;
$firstdecrip[] = $img2descrip;
}
if(!empty($_SESSION['previouslargephoto3'])){
$img3 = $_SESSION['previouslargephoto3'];
$img3descrip = $_SESSION['propthreedescrip'];
$firstimg[] = $img3;
$firstdecrip[] = $img3descrip;
}
if(!empty($_SESSION['previouslargephoto4'])){
$img4 = $_SESSION['previouslargephoto4'];
$img4descrip = $_SESSION['propfourdescrip'];
$firstimg[] = $img4;
$firstdecrip[] = $img4descrip;
}
if(!empty($_SESSION['previouslargephoto5'])){
$img5 = $_SESSION['previouslargephoto5'];
$img5descrip = $_SESSION['propfivedescrip'];
$firstimg[] = $img5;
$firstdecrip[] = $img5descrip;
}
if(!empty($_SESSION['previouslargephoto6'])){
$img6 = $_SESSION['previouslargephoto6'];
$img6descrip = $_SESSION['propsixdescrip'];
$firstimg[] = $img6;
$firstdecrip[] = $img6descrip;
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Simple Gallery</title>
<script type="text/javascript">
var num=1;
imgArray = [
<?php if(!empty($_SESSION['previouslargephoto1'])){?>['<?php echo $img1;?>', '<?php echo $img1descrip;?>'],<?php }?>
<?php if(!empty($_SESSION['previouslargephoto2'])){?>['<?php echo $img2;?>', '<?php echo $img2descrip;?>'],<?php }?>
<?php if(!empty($_SESSION['previouslargephoto3'])){?>['<?php echo $img3;?>', '<?php echo $img3descrip;?>'],<?php }?>
<?php if(!empty($_SESSION['previouslargephoto4'])){?>['<?php echo $img4;?>', '<?php echo $img4descrip;?>'],<?php }?>
<?php if(!empty($_SESSION['previouslargephoto5'])){?>['<?php echo $img5;?>', '<?php echo $img5descrip;?>'],<?php }?>
<?php if(!empty($_SESSION['previouslargephoto6'])){?>['<?php echo $img6;?>', '<?php echo $img6descrip;?>']<?php }?>
// Note: no comma after last entry
]
function slideshow(slide_num) {
document.getElementById('mypic').src=imgArray[slide_num][0];
document.getElementById('mypic').alt=imgArray[slide_num][1];
document.getElementById('burns').innerHTML=imgArray[slide_num][1];
}
function slideshowUp() {
num++;
num = num % imgArray.length;
slideshow(num);
}
function slideshowBack() {
num--; if (num < 0) {num=imgArray.length-1;}
num = num % imgArray.length;
slideshow(num);
// location.href="example.php?num=" + num;
}
</script>
</head>
<body onLoad="slideshow(0)">
<div style="text-align: center">
<!-- Place the first image here -->
<?php
$img1 = $firstimg[0];
$img1descrip = $firstdecrip[0];
$ttimages = count($firstimg,0);
/*if(isset($_GET['num'])){
echo $num=$_GET['num'];
}
if(!isset($_GET['num'])){
echo $num=1;
}*/
?>
<img id='mypic' src="<?php echo $img1;?>" name='mypic' border="0" height="150" width="200">
<br>
<!-- Place the text for the first image here -->
<div id="burns"><?php echo $img1descrip;?></div>
<p>
<a href="#" onClick="slideshowBack(); return false;">« Previous</a> 1 of <?php echo $ttimages;?> <a href="#" onClick="slideshowUp(); return false;"> Next »</a>
</div>
</body>
</html>
- <?php
- ob_start();
- session_start();
- if(!empty($_SESSION['previouslargephoto1'])){
- $img1 = $_SESSION['previouslargephoto1'];
- $img1descrip = $_SESSION['proponedescrip'];
- $firstimg[] = $img1;
- $firstdecrip[] = $img1descrip;
- $count[] = 1;
- }
- if(!empty($_SESSION['previouslargephoto2'])){
- $img2 = $_SESSION['previouslargephoto2'];
- $img2descrip = $_SESSION['proptwodescrip'];
- $firstimg[] = $img2;
- $firstdecrip[] = $img2descrip;
- }
- if(!empty($_SESSION['previouslargephoto3'])){
- $img3 = $_SESSION['previouslargephoto3'];
- $img3descrip = $_SESSION['propthreedescrip'];
- $firstimg[] = $img3;
- $firstdecrip[] = $img3descrip;
- }
- if(!empty($_SESSION['previouslargephoto4'])){
- $img4 = $_SESSION['previouslargephoto4'];
- $img4descrip = $_SESSION['propfourdescrip'];
- $firstimg[] = $img4;
- $firstdecrip[] = $img4descrip;
- }
- if(!empty($_SESSION['previouslargephoto5'])){
- $img5 = $_SESSION['previouslargephoto5'];
- $img5descrip = $_SESSION['propfivedescrip'];
- $firstimg[] = $img5;
- $firstdecrip[] = $img5descrip;
- }
- if(!empty($_SESSION['previouslargephoto6'])){
- $img6 = $_SESSION['previouslargephoto6'];
- $img6descrip = $_SESSION['propsixdescrip'];
- $firstimg[] = $img6;
- $firstdecrip[] = $img6descrip;
- }
- ?>
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <title>Simple Gallery</title>
- <script type="text/javascript">
- var num=1;
- imgArray = [
- <?php if(!empty($_SESSION['previouslargephoto1'])){?>['<?php echo $img1;?>', '<?php echo $img1descrip;?>'],<?php }?>
- <?php if(!empty($_SESSION['previouslargephoto2'])){?>['<?php echo $img2;?>', '<?php echo $img2descrip;?>'],<?php }?>
- <?php if(!empty($_SESSION['previouslargephoto3'])){?>['<?php echo $img3;?>', '<?php echo $img3descrip;?>'],<?php }?>
- <?php if(!empty($_SESSION['previouslargephoto4'])){?>['<?php echo $img4;?>', '<?php echo $img4descrip;?>'],<?php }?>
- <?php if(!empty($_SESSION['previouslargephoto5'])){?>['<?php echo $img5;?>', '<?php echo $img5descrip;?>'],<?php }?>
- <?php if(!empty($_SESSION['previouslargephoto6'])){?>['<?php echo $img6;?>', '<?php echo $img6descrip;?>']<?php }?>
- // Note: no comma after last entry
- ]
- function slideshow(slide_num) {
- document.getElementById('mypic').src=imgArray[slide_num][0];
- document.getElementById('mypic').alt=imgArray[slide_num][1];
- document.getElementById('burns').innerHTML=imgArray[slide_num][1];
- }
- function slideshowUp() {
- num++;
- num = num % imgArray.length;
- slideshow(num);
- }
- function slideshowBack() {
- num--; if (num < 0) {num=imgArray.length-1;}
- num = num % imgArray.length;
- slideshow(num);
- // location.href="example.php?num=" + num;
- }
- </script>
- </head>
- <body onLoad="slideshow(0)">
- <div style="text-align: center">
- <!-- Place the first image here -->
- <?php
- $img1 = $firstimg[0];
- $img1descrip = $firstdecrip[0];
- $ttimages = count($firstimg,0);
- /*if(isset($_GET['num'])){
- echo $num=$_GET['num'];
- }
- if(!isset($_GET['num'])){
- echo $num=1;
- }*/
- ?>
- <img id='mypic' src="<?php echo $img1;?>" name='mypic' border="0" height="150" width="200">
- <br>
- <!-- Place the text for the first image here -->
- <div id="burns"><?php echo $img1descrip;?></div>
- <p>
- <a href="#" onClick="slideshowBack(); return false;">« Previous</a> 1 of <?php echo $ttimages;?> <a href="#" onClick="slideshowUp(); return false;"> Next »</a>
- </div>
- </body>
- </html>
- Anonymous
- Bot


- Joined: 25 Feb 2008
- Posts: ?
- Loc: Ozzuland
- Status: Online
March 27th, 2011, 12:54 pm
Page 1 of 1
To Reply to this topic you need to LOGIN or REGISTER. It is free.
Post Information
- Total Posts in this topic: 1 post
- Users browsing this forum: No registered users and 211 guests
- You cannot post new topics in this forum
- You cannot reply to topics in this forum
- You cannot edit your posts in this forum
- You cannot delete your posts in this forum
- You cannot post attachments in this forum
