firstly how are you getting the current image to display?

    dagon;10928770 wrote:

    firstly how are you getting the current image to display?

    dagon! hello there...good looking out on the reply -i got a php page with an image embeded in it with a previous and next button under it that when you click i got a basic link to the next page.....i just wanted to know if there is a for loop or something that i could put in there or some basic code so all i have to do is change one line of code for each new photo gallery i make pointing to a specific folder where the images are....

    .....just images without any descriptions or text

    here is the code by the way thanks again!!!!

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/staticPhotoGallery.dwt.php" codeOutsideHTMLIsLocked="false" -->
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <!-- InstanceBeginEditable name="doctitle" -->
    <title>Front Yard</title>
    <!-- InstanceEndEditable -->
    <link href="/rentalGallery.css" rel="stylesheet" type="text/css" />
    <!-- InstanceBeginEditable name="head" --><!-- InstanceEndEditable -->
    </head>

    <body>
    <!-- InstanceBeginEditable name="Editable" -->
    <div id="imageGalleryMainPhoto">
    <p><img src="/images/rentals/1619-st-denis-ave-norfolk-va-23509/st-denis-1-bedroom/frontyard.JPG" alt="front yard" width="667" height="500" /><br />
    <a href="/20.php">Previous</a> &nbsp;&nbsp; <a href="/2.php">Next</a></p>
    </div>
    <!-- InstanceEndEditable -->
    </body>
    <!-- InstanceEnd --></html>

      Semi working script to do what you ask. scandir includes directories, so check for is_file will be needed. Even if you only keep files in your directory, both . and .. are always included.

      Also, non image files should probably be detected.

      And finally, some kind of end case handling. i.e. what to do if you're viewing the first or last file.

      $dirname = './images/';
      $files = scandir($dirname);
      $key = array_search(basename($_GET['currentFile']), $files);
      
      if (isset($_GET['previous']))
      	$showFile = $files[$key - 1];
      else if (isset($_GET['next']))
      	$showFile = $files[$key + 1];
      else $showFile = $files[2];
      
      
      echo '<img src="/images/'.$showFile.'" alt=""/><br/>';
      echo '<a href="?previous=1&amp;currentFile='.urlencode($dirname.$showFile).'">Previous</a><br/>';
      echo '<a href="?next=1&amp;currentFile='.urlencode($dirname.$showFile).'">Next</a><br/>';
      
        johanafm;10928775 wrote:

        Semi working script to do what you ask. scandir includes directories, so check for is_file will be needed. Even if you only keep files in your directory, both . and .. are always included.

        Also, non image files should probably be detected.

        And finally, some kind of end case handling. i.e. what to do if you're viewing the first or last file.

        $dirname = './images/';
        $files = scandir($dirname);
        $key = array_search(basename($_GET['currentFile']), $files);
        
        if (isset($_GET['previous']))
        	$showFile = $files[$key - 1];
        else if (isset($_GET['next']))
        	$showFile = $files[$key + 1];
        else $showFile = $files[2];
        
        
        echo '<img src="/images/'.$showFile.'" alt=""/><br/>';
        echo '<a href="?previous=1&amp;currentFile='.urlencode($dirname.$showFile).'">Previous</a><br/>';
        echo '<a href="?next=1&amp;currentFile='.urlencode($dirname.$showFile).'">Next</a><br/>';
        

        fm you are in the house...worked so good it made me want to curse!

        just one thing though mr senior member in the house with the extra props!!!

        i get this above the first image

        Notice: Undefined index: currentFile in C:\vhosts\zandiconstruction\phpBuiildersPhotoTest.php on line 11

        then everything is fine and dandy do i have to declare currentFile in order for that not to show?

        here is my code

        <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
        <html xmlns="http://www.w3.org/1999/xhtml">
        <head>
        <title>Untitled Document</title>
        </head>

        <body>
        <?php
        $dirname = 'phpBuildersPhotoTest/';
        $files = scandir($dirname);
        $key = array_search(basename($_GET['currentFile']), $files);

        if (isset($GET['previous']))
        $showFile = $files[$key - 1];
        else if (isset($
        GET['next']))
        $showFile = $files[$key + 1];
        else $showFile = $files[2];

        echo '<img src="phpBuildersPhotoTest/'.$showFile.'" alt=""/><br/>';
        echo '<a href="?previous=1&amp;currentFile='.urlencode($dirname.$showFile).'">Previous</a><br/>';
        echo '<a href="?next=1&amp;currentFile='.urlencode($dirname.$showFile).'">Next</a><br/>';
        ?>

        </body>

        god knows thanks again for the code....saved so much time,,,,,boy i need to work on my php:eek:

          Notice: Undefined index: currentFile in C:\vhosts\zandiconstruction\phpBuiildersPhotoTest.php on line 11

          This means that your using an array index that does not exist.

          When you first load the page, it probably looks something like
          http://yourdomain.com/script.php
          which means that there is nothing in $_GET, until the user clicks one of the links which sets the currentFile element through the href attribute with currentFile=...

          if (isset($_GET['currentFile'])) {
          	$dirname = './images/';
          	$files = scandir($dirname);
          	$key = array_search(basename($_GET['currentFile']), $files);
          
          if (isset($_GET['previous']))
              $showFile = $files[$key - 1];
          else if (isset($_GET['next']))
              $showFile = $files[$key + 1];
          else $showFile = $files[2];
          }
          else $showFile = "yourdefaultimage.jpg";
          

            fm whats up bro,

            thanks again for the extra slamming code and skills...only problem now if you could hook that up is that i still don't get a default picture in but i also get this error as well

            Notice: Undefined variable: dirname in C:\vhosts\zandiconstruction\phpBuiildersPhotoTest.php on line 23
            Previous

            Notice: Undefined variable: dirname in C:\vhosts\zandiconstruction\phpBuiildersPhotoTest.php on line 24
            Next

            .....then you click on next and that goes away and you get photo's

            i am going to paste my code but i am assuming you have to set the prvious and next to showfile? or is it something more like onload function....im looking at php.net and still clueless

            here is my code

            <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
            <html xmlns="http://www.w3.org/1999/xhtml">
            <head>
            <title>Untitled Document</title>
            </head>

            <body>
            <?php

            if (isset($GET['currentFile'])) {
            $dirname = 'phpBuildersPhotoTest/';
            $files = scandir($dirname);
            $key = array_search(basename($
            GET['currentFile']), $files);
            if (isset($GET['previous']))
            $showFile = $files[$key - 1];
            else if (isset($
            GET['next']))
            $showFile = $files[$key + 1];
            else $showFile = $files[2];
            }
            else $showFile = "phpBuildersPhotoTest/buck_palace.jpg";

            echo '<img src="phpBuildersPhotoTest/'.$showFile.'" alt=""/><br/>';
            echo '<a href="?previous=1&amp;currentFile='.urlencode($dirname.$showFile).'">Previous</a><br/>';
            echo '<a href="?next=1&amp;currentFile='.urlencode($dirname.$showFile).'">Next</a><br/>';
            ?>

            </body>

            johanafm;10928801 wrote:

            This means that your using an array index that does not exist.

            When you first load the page, it probably looks something like
            http://yourdomain.com/script.php
            which means that there is nothing in $_GET, until the user clicks one of the links which sets the currentFile element through the href attribute with currentFile=...

            if (isset($_GET['currentFile'])) {
            	$dirname = './images/';
            	$files = scandir($dirname);
            	$key = array_search(basename($_GET['currentFile']), $files);
            
            if (isset($_GET['previous']))
                $showFile = $files[$key - 1];
            else if (isset($_GET['next']))
                $showFile = $files[$key + 1];
            else $showFile = $files[2];
            }
            else $showFile = "yourdefaultimage.jpg";
            

              Oh, thats $dirname is defined inside the if check for currentFile being set. Move dirname definition outside the if block.

                john what up man!!!

                yo bro i am almost done with this one i moved teh $dirname outside of the if statment and all the errors are now gone but now there is still no picture when i load the page into my browser, until i hit next then everything works out

                i tried messing around with showfile but came to no good result

                here is my code

                <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
                <html xmlns="http://www.w3.org/1999/xhtml">
                <head>
                <title>Untitled Document</title>
                </head>

                <body>
                <?php
                $dirname = 'phpBuildersPhotoTest/';
                $files = scandir($dirname);

                if (isset($_GET['currentFile'])) {
                    $key = array_search(basename($_GET['currentFile']), $files);
                
                if (isset($_GET['previous']))
                    $showFile = $files[$key - 1];
                else if (isset($_GET['next']))
                    $showFile = $files[$key + 1];
                else $showFile = $files[2];

                }
                else $showFile = "phpBuildersPhotoTest/buck_palace.jpg";

                echo '<img src="phpBuildersPhotoTest/'.$showFile.'" alt=""/><br/>';
                echo '<a href="?previous=1&amp;currentFile='.urlencode($dirname.$showFile).'">Previous</a><br/>';
                echo '<a href="?next=1&amp;currentFile='.urlencode($dirname.$showFile).'">Next</a><br/>';
                ?>

                </body>

                i tried just deleting echo img src phpbuildersphototest/ and just leaving the .$showFile it works then but the next and previous buttons don't work then

                .......:eek: once this works im ready to drink a beer!

                johanafm;10928900 wrote:

                Oh, thats $dirname is defined inside the if check for currentFile being set. Move dirname definition outside the if block.

                  This should work

                  else $showFile = "buck_palace.jpg";
                  
                  echo '<img src="'.$dirname.$showFile.'" alt=""/><br/>'; 
                  

                    what up fm man the powers of the mind bro, i know you have spent your fare share staring at code i respect that admire that

                    good looking out again this was the solution, and very interesting it was....what an outstanding script, add a little css and you have an instant photo gallery

                    .....im working on this tutorial in david powers book
                    The Essential Guide to Dreamweaver with CSS, Ajax, and PHP~tqw~_darksiderg

                    i created an xml photo gallery where you click on the thumbnail it will change the main photo..l..works great but not in IE

                    i know this type of photo slide show with no text isn't a widely used one as far as descriptions, but works like hell until i fix the other one!!!

                    thanks again partner!

                    johanafm;10929118 wrote:

                    This should work

                    else $showFile = "buck_palace.jpg";
                    
                    echo '<img src="'.$dirname.$showFile.'" alt=""/><br/>'; 
                    
                      23 days later
                      johanafm;10929118 wrote:

                      This should work

                      else $showFile = "buck_palace.jpg";
                      
                      echo '<img src="'.$dirname.$showFile.'" alt=""/><br/>'; 
                      

                      what up johnfm,

                      thanks again bro for the input on the last issue i had with php code...i got the script all loaded up and ready to go, got it on my site and looks like scandisk doesn't work on my server that i am paying for at inmotionhosting.com

                      is there anyway around it????

                      you can find your script you gave me at the bottom of the home page at www.zandiconstruction.com where it says "click here for photo slide show of hardwoodstairs"

                      here is my final script wiht css

                      thanks again!

                      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
                      <html xmlns="http://www.w3.org/1999/xhtml">
                      <head>
                      <title>Untitled Document</title>
                      <style type="text/css">
                      <!--

                      a:visited {
                      color: #0000FF;
                      text-decoration: none;
                      }
                      a:active {
                      color: #0000FF;
                      text-decoration: none;
                      }
                      a:link {
                      color: #0000FF;
                      text-decoration: none;
                      }
                      a:hover {
                      color: #FF0000;
                      text-decoration: none;
                      }
                      .previousButton {
                      float: inherit;
                      margin-right: 10px;
                      }
                      img {
                      background-position: center;
                      margin-top: 0px;
                      }
                      -->
                      </style>
                      </head>

                      <body>
                      <center>
                      <?php
                      $dirname = 'hardwood-stairs-gallery-compressed/';
                      $files = scandir($dirname);

                          if (isset($_GET['currentFile'])) {
                              $key = array_search(basename($_GET['currentFile']), $files);
                      
                          if (isset($_GET['previous']))
                              $showFile = $files[$key - 1];
                          else if (isset($_GET['next']))
                              $showFile = $files[$key + 1];
                          else $showFile = $files[2];
                      }
                      else $showFile = "carpet-stairs.JPG"; 
                      
                      
                      echo '<a href="?previous=1&amp;currentFile='.urlencode($dirname.$showFile).'"><span class="previousButton">Previous</span></a>';
                      echo '<a href="?next=1&amp;currentFile='.urlencode($dirname.$showFile).'">Next</a><br/>'; 
                      echo '<img src="'.$dirname.$showFile.'" alt=""/><br/>';
                      ?>

                      </center>
                      </body>

                        what up johnfm,

                        thanks again bro for the input on the last issue i had with php code...i got the script all loaded up and ready to go, got it on my site and looks like scandisk doesn't work on my server that i am paying for at inmotionhosting.com

                        is there anyway around it????

                        you can find your script you gave me at the bottom of the home page at www.zandiconstruction.com where it says "click here for photo slide show of hardwoodstairs"

                        here is my final script wiht css

                        thanks again!

                        <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
                        <html xmlns="http://www.w3.org/1999/xhtml">
                        <head>
                        <title>Untitled Document</title>
                        <style type="text/css">
                        <!--

                        a:visited {
                        color: #0000FF;
                        text-decoration: none;
                        }
                        a:active {
                        color: #0000FF;
                        text-decoration: none;
                        }
                        a:link {
                        color: #0000FF;
                        text-decoration: none;
                        }
                        a:hover {
                        color: #FF0000;
                        text-decoration: none;
                        }
                        .previousButton {
                        float: inherit;
                        margin-right: 10px;
                        }
                        img {
                        background-position: center;
                        margin-top: 0px;
                        }
                        -->
                        </style>
                        </head>

                        <body>
                        <center>
                        <?php
                        $dirname = 'hardwood-stairs-gallery-compressed/';
                        $files = scandir($dirname);

                        if (isset($GET['currentFile'])) {
                        $key = array_search(basename($
                        GET['currentFile']), $files);

                        if (isset($GET['previous']))
                        $showFile = $files[$key - 1];
                        else if (isset($
                        GET['next']))
                        $showFile = $files[$key + 1];
                        else $showFile = $files[2];
                        }
                        else $showFile = "carpet-stairs.JPG";

                        echo '<a href="?previous=1&amp;currentFile='.urlencode($dirname.$showFile).'"><span class="previousButton">Previous</span></a>';
                        echo '<a href="?next=1&amp;currentFile='.urlencode($dirname.$showFile).'">Next</a><br/>';
                        echo '<img src="'.$dirname.$showFile.'" alt=""/><br/>';
                        ?>
                        </center>
                        </body>

                          Write a Reply...