Username: Save?
Password:
Home Forum Links Search Login Register*
    News: Keep The TechnoWorldInc.com Community Clean: Read Guidelines Here.
Recent Updates
[May 17, 2024, 05:02:16 PM]

[May 17, 2024, 05:02:16 PM]

[May 17, 2024, 05:02:16 PM]

[May 17, 2024, 05:02:16 PM]

[April 24, 2024, 11:48:22 AM]

[April 24, 2024, 11:48:22 AM]

[April 24, 2024, 11:48:22 AM]

[April 24, 2024, 11:48:22 AM]

[April 03, 2024, 06:11:00 PM]

[April 03, 2024, 06:11:00 PM]

[April 03, 2024, 06:11:00 PM]

[April 03, 2024, 06:11:00 PM]

[March 06, 2024, 02:45:27 PM]
Subscriptions
Get Latest Tech Updates For Free!
Resources
   Travelikers
   Funistan
   PrettyGalz
   Techlap
   FreeThemes
   Videsta
   Glamistan
   BachatMela
   GlamGalz
   Techzug
   Vidsage
   Funzug
   WorldHostInc
   Funfani
   FilmyMama
   Uploaded.Tech
   MegaPixelShop
   Netens
   Funotic
   FreeJobsInc
   FilesPark
Participate in the fastest growing Technical Encyclopedia! This website is 100% Free. Please register or login using the login box above if you have already registered. You will need to be logged in to reply, make new topics and to access all the areas. Registration is free! Click Here To Register.
+ Techno World Inc - The Best Technical Encyclopedia Online! » Forum » THE TECHNO CLUB [ TECHNOWORLDINC.COM ] » Programming Zone » PHP
 Photo gallery with next previous navigation in php
Pages: [1]   Go Down
  Print  
Author Topic: Photo gallery with next previous navigation in php  (Read 983 times)
Hellraiser
TWI Trailblazer
*******



Karma: 3
Offline Offline

Posts: 2476


View Profile
Photo gallery with next previous navigation in php
« Posted: August 29, 2007, 10:25:12 AM »


Photo gallery with next previous navigation in php

Build a photo gallery with next previous navigation system.

As PHPJavascript.com is all about dynamic websites, my script is written in PHP (PHP is my best friend in the world of programming).

Code:
<? 
$total=5;
if(isset($_REQUEST["i"]))
$i=$_REQUEST["i"]; else $i=1;
$next=$i+1; $previous=$i-1;

?>
<? if($previous>0) {?> <a href="photogallery.php?&i=<? echo $previous;?>">Previous</a> <? } ?>
<img src="<?echo $i?>.jpg">
<? if($next<=$total) { ?> <a href="photogallery.php?&i=<? echo $next;?>">Next</a> <? } ?>

Explanation

   1. First make a folder and save lets say 5 images in it. Name the images 1.jpg, 2.jpg, 3.jpg, 4.jpg and 5.jpg respectively
   2. declare $total=5 where 5 is the no of images you have
   3. declare $i value. if $i value is already set than get that value else make $i=1
      if(isset($_REQUEST["i"])) $i=$_REQUEST["i"]; else $i=1;
   4. declare img tag <img src=<?echo $i?>.jpg> where $i stores the name of the image followed by the extension ".jpg"
   5. Now for next previous navigation declare variables $previous and $next. $next=$i+1; $previous=$i-1;
   6. Add previous and next link around the image tag with validation.
      <? if($previous>0) {?> <a href="photogallery.php?&i=<? echo $previous;?>">Previous[/url] <? } ?>
      <img src="<?echo $i?>.jpg">
      <? if($next<=$total) { ?> <a href="photogallery.php?&i=<? echo $next;?>">Next[/url] <? } ?>
   7. We are using url to transfer the value of $i (photogallery.php?&i=<? echo $next;?>)
   8. if $previous value is less than 0 than remove previous link and if next value is more than the total no of images than remove next link
   9. Hope that was easy to understand and implement

Download the Attached File below
[Note: If u can't see any file attached, Please Register and Login with your id.]

« Last Edit: August 29, 2007, 10:26:40 AM by Mark David » Logged

Pages: [1]   Go Up
  Print  
 
Jump to:  

Copyright © 2006-2023 TechnoWorldInc.com. All Rights Reserved. Privacy Policy | Disclaimer
Page created in 0.258 seconds with 24 queries.