showing current page number in javascript image slideshow

  • tiffix
  • Student
  • Student
  • User avatar
  • Posts: 65
  • Loc: kenya

Post 3+ Months Ago

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>&nbsp;1 of <?php echo $ttimages;?>&nbsp;<a href="#" onClick="slideshowUp(); return false;"> Next »</a>
</div>
</body>
</html>
  1. <?php
  2. ob_start();
  3. session_start();
  4. if(!empty($_SESSION['previouslargephoto1'])){
  5.     $img1            = $_SESSION['previouslargephoto1'];
  6.     $img1descrip    = $_SESSION['proponedescrip'];
  7.     $firstimg[]     = $img1;
  8.     $firstdecrip[]     = $img1descrip;
  9.     $count[]        = 1;
  10. }
  11. if(!empty($_SESSION['previouslargephoto2'])){
  12.     $img2            = $_SESSION['previouslargephoto2'];
  13.     $img2descrip    = $_SESSION['proptwodescrip'];
  14.     $firstimg[]     = $img2;
  15.     $firstdecrip[]     = $img2descrip;
  16. }
  17. if(!empty($_SESSION['previouslargephoto3'])){
  18.     $img3            = $_SESSION['previouslargephoto3'];
  19.     $img3descrip    = $_SESSION['propthreedescrip'];
  20.     $firstimg[]     = $img3;
  21.     $firstdecrip[]     = $img3descrip;
  22. }
  23. if(!empty($_SESSION['previouslargephoto4'])){
  24.     $img4            = $_SESSION['previouslargephoto4'];
  25.     $img4descrip    = $_SESSION['propfourdescrip'];
  26.     $firstimg[]     = $img4;
  27.     $firstdecrip[]     = $img4descrip;
  28. }
  29. if(!empty($_SESSION['previouslargephoto5'])){
  30.     $img5            = $_SESSION['previouslargephoto5'];
  31.     $img5descrip    = $_SESSION['propfivedescrip'];
  32.     $firstimg[]     = $img5;
  33.     $firstdecrip[]     = $img5descrip;    
  34. }
  35. if(!empty($_SESSION['previouslargephoto6'])){
  36.     $img6            = $_SESSION['previouslargephoto6'];
  37.     $img6descrip    = $_SESSION['propsixdescrip'];
  38.     $firstimg[]     = $img6;
  39.     $firstdecrip[]     = $img6descrip;    
  40. }
  41. ?>
  42. <html>
  43. <head>
  44. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  45. <title>Simple Gallery</title>
  46. <script type="text/javascript">
  47. var num=1;
  48. imgArray = [
  49. <?php if(!empty($_SESSION['previouslargephoto1'])){?>['<?php echo $img1;?>', '<?php echo $img1descrip;?>'],<?php }?>
  50. <?php if(!empty($_SESSION['previouslargephoto2'])){?>['<?php echo $img2;?>', '<?php echo $img2descrip;?>'],<?php }?>
  51. <?php if(!empty($_SESSION['previouslargephoto3'])){?>['<?php echo $img3;?>', '<?php echo $img3descrip;?>'],<?php }?>
  52. <?php if(!empty($_SESSION['previouslargephoto4'])){?>['<?php echo $img4;?>', '<?php echo $img4descrip;?>'],<?php }?>
  53. <?php if(!empty($_SESSION['previouslargephoto5'])){?>['<?php echo $img5;?>', '<?php echo $img5descrip;?>'],<?php }?>
  54. <?php if(!empty($_SESSION['previouslargephoto6'])){?>['<?php echo $img6;?>', '<?php echo $img6descrip;?>']<?php }?>
  55. // Note: no comma after last entry
  56. ]
  57. function slideshow(slide_num) {
  58.  document.getElementById('mypic').src=imgArray[slide_num][0];
  59.  document.getElementById('mypic').alt=imgArray[slide_num][1];
  60.  document.getElementById('burns').innerHTML=imgArray[slide_num][1];
  61. }
  62. function slideshowUp() {
  63.  num++;
  64.  num = num % imgArray.length;
  65.  slideshow(num);
  66. }
  67. function slideshowBack() {
  68.  num--; if (num < 0) {num=imgArray.length-1;}
  69.  num = num % imgArray.length;
  70.  slideshow(num);
  71. // location.href="example.php?num=" + num;
  72. }
  73. </script>
  74. </head>
  75. <body onLoad="slideshow(0)">
  76. <div style="text-align: center">
  77. <!-- Place the first image here -->
  78. <?php
  79.     $img1         =    $firstimg[0];
  80.     $img1descrip =    $firstdecrip[0];
  81.     
  82.     $ttimages     = count($firstimg,0);
  83.     
  84.     /*if(isset($_GET['num'])){
  85.         echo $num=$_GET['num'];
  86.     }
  87.     
  88.     if(!isset($_GET['num'])){
  89.         echo $num=1;
  90.     }*/
  91.         
  92.     
  93. ?>
  94. <img id='mypic' src="<?php echo $img1;?>" name='mypic' border="0" height="150" width="200">
  95. <br>
  96. <!-- Place the text for the first image here -->
  97. <div id="burns"><?php echo $img1descrip;?></div>
  98. <p>
  99. <a href="#" onClick="slideshowBack(); return false;">« Previous</a>&nbsp;1 of <?php echo $ttimages;?>&nbsp;<a href="#" onClick="slideshowUp(); return false;"> Next »</a>
  100. </div>
  101. </body>
  102. </html>
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

Post Information

  • Total Posts in this topic: 1 post
  • Users browsing this forum: No registered users and 56 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
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.