THe script below is suppose to make an array, in which a folder in a website has images that are named: 001.jpg, 002.jpg, 003.jpg, and all the way to 63....

so I want to make a script that will loop itself and display all these images and then make a back and forward button so that people can view them 1 by 1...

<html>
<head>
<title>Album</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<?
$data1 = "001.jpg";//Enter base image name here
$datalength = 63;//Enter the maximum # of the image name here (ex: 9.jpg = 9)
for ($i = 0; $i < $datalength; $i++){
$format = array("00" .$i. ".jpg");
echo "<img src='http://mysite.com/" .$format. "' border='0' height='400' width='600' alt='photos'>";//define image places
}
?>
</body>
</html>

i need help.... thx for your time

    Try this.

    <html>
    <head>
    <title>Album</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>
    
    <body>
    <?
    //Enter base image name here -- don't see you need base name 
    $datalength = 63;//Enter the maximum # of the image name here (ex: 9.jpg = 9)
    for ($i = 0; $i < $datalength; $i++){
    echo "<img src='http://mysite.com/00" .$i. ".jpg' border='0' height='400' width='600' alt='photos'>";//define image places
    }
    ?>
    </body>
    </html>
    

      I'm working on something similar now actually... read the directory contents for images with jpg gif or bmp extensions... add the filenames to an array, and use next/previous buttons to step to the next element of the array.

        Originally posted by webdes03
        I'm working on something similar now actually... read the directory contents for images with jpg gif or bmp extensions... add the filenames to an array, and use next/previous buttons to step to the next element of the array.

        i did this, for gif and jpg's only tho. not too hard

          Just commenting, be carefull with your image filenames. For example: 001.jpg is fine although 0024.jpg i'm guessing is not? You would want 024.jpg - this script would make it 0024.jpg.

          Just thought i'd mention it 😛

          Jack.

            Originally posted by Nixon
            Just commenting, be carefull with your image filenames. For example: 001.jpg is fine although 0024.jpg i'm guessing is not? You would want 024.jpg - this script would make it 0024.jpg.

            Just thought i'd mention it 😛

            Jack.

            haha, good point. well i'm sure that he can get that 🙂

              thx for your help... but how do I make a picture and make it 1 per page...
              and put back and next buttons

              wouldnt i need an array?
              and make every [1],[2] a different page?
              how would i do that?

                Originally posted by Dax
                thx for your help... but how do I make a picture and make it 1 per page...
                and put back and next buttons

                wouldnt i need an array?
                and make every [1],[2] a different page?
                how would i do that?

                a while statement and alot of math 🙂

                  i would greatly appreciate it if i could have the script after i click on thumbnail on your site...
                  thats exactly what i need

                    Originally posted by Dax
                    i would greatly appreciate it if i could have the script after i click on thumbnail on your site...
                    thats exactly what i need

                    here's the one I used to use (now I use db's for my images)

                    <?
                    
                    $incldir="thumbs/"; // thumbnail directory
                    $directory="images/"; // image directory
                    $pagenum=$QUERY_STRING;
                    
                    if ( $pagenum == NULL ) {  
                    $pagenum=1; } $realpage=$pagenum - 1; $linecount=0; $d2 = dir($incldir); while($entry=$d2->read()) { if ( $entry != "." && $entry != ".." && $entry != ".total" ) { $linecount++; } } //change the 10 to whatever # per page $pagecount=$realpage * 10 + 1; $endcount=$pagecount + 10; $totalpages=floor($linecount / 10); $rtotalpages=$linecount % 10; if ( $rtotalpages >= 1 ) { $totalpages++; } $currcount=1; $d2 = dir($incldir); while($entry=$d2->read()) { if ( $entry != "." && $entry != ".." ) { if ( $currcount < $endcount && $currcount >= $pagecount ) { echo "<a href=\"".$directory."${entry}\"><img src=\"".$incldir."${entry}\" border=0></a>&nbsp;&nbsp;"; } $currcount++; } } echo "<br><Br>"; $back=$pagenum - 1; $next=$pagenum + 1; if ( $back < "1" ) { echo "&nbsp;&nbsp;"; } else { echo "<A href=\"".$PHP_SELF."?$back\">&lt;&lt;</a>"; echo "&nbsp;"; } $totalpagecount=1; while ( $totalpagecount <= $totalpages ) { if ( $totalpagecount == $pagenum ) { echo "<b>$totalpagecount</b>&nbsp;"; } else { echo "<a href=\"".$PHP_SELF."?$totalpagecount\">$totalpagecount</a>&nbsp;"; } $totalpagecount++; } if ( $next > $totalpages ) { echo "&nbsp;&nbsp;"; } else { echo "<A href=\"".$PHP_SELF."?$next\">&gt;&gt;</a>"; } ?>

                    basically, your images have to have the same image names for this to work, your thumbs go in your $incldir and your regular images go in your $directory.

                    If you have GD V 2.0 installed on your server, you can use this... just point the img src to thumb.php?url=${entry}

                    <?php
                     header("Content-type: image/jpeg");
                    
                    $filename = $url;
                    $filename = str_replace(" ", "%20", $filename);
                    $filen = $_FILES[filename][name];
                    $filet = $_FILES[filename][type];
                    
                    $imageInfo = getimagesize($filename);
                    $old_w = $imageInfo['0'];
                    $old_h = $imageInfo['1'];
                    
                    if ($old_w>=$old_h) 
                     { 
                        $width=$size; 
                        $height = ($width/$old_w)*$old_h; 
                     } 
                      else 
                     { 
                        $height=$size; 
                        $width = ($height/$old_h)*$old_w; 
                     } 
                    $img_src ="$filename";
                    $dst_img=ImageCreateTrueColor($width,$height);
                    
                    $src_img=ImageCreateFromJpeg("$filename"); 
                    
                    imagecopyresampled($dst_img,$src_img,0,0,0,0,$width,$height,$old_w,$old_h);
                    
                    
                    ImageJpeg($dst_img, '', 75); 
                    ?>
                    
                    

                      thx for ur help but
                      it doesnt work

                      i just want the second part of ur script
                      but it doesnt work

                      i have a folder Christmas 2003/
                      full of images named: 001.jpg, 002.jpg

                      i editted ur script but i m not sure how to finish it...

                      <?php 
                      header("Content-type: image/jpeg");
                      $i = 1;
                      $filename = "00".$i.".jpg";/*it is starting with 1, and i want it to go till 63*\
                      $i++;
                      array($filename)\* i want to loop the image names till 63, and want them to just be displayed 1 by 1... *\
                      
                      $filename = str_replace(" ", "%20", $filename); 
                      $filen = $_FILES[filename][name]; 
                      $filet = $_FILES[filename][type]; 
                      
                      $imageInfo = getimagesize($filename); 
                      $old_w = $imageInfo['0']; 
                      $old_h = $imageInfo['1']; 
                      
                      if ($old_w>=$old_h)  
                      {
                      $width=$size;
                      $height = ($width/$old_w)*$old_h;
                      }
                      else
                      {
                      $height=$size;
                      $width = ($height/$old_h)*$old_w;
                      }
                      $img_src ="$filename"; $dst_img=ImageCreateTrueColor($width,$height); $src_img=ImageCreateFromJpeg("$filename"); imagecopyresampled($dst_img,$src_img,0,0,0,0,$width,$height,$old_w,$old_h); ImageJpeg($dst_img, '', 75);
                      ?>

                      i have no idea what the rest of ur script is used for

                        the rest of the script parses the pages.. < Prev 123 Next> and such.

                        this will grab the images in whatever folder you tell it to, as long as you have thumbnails made, or you can use GD 2.0 to make them, which I explained how to do above.

                        good luck

                          Thank you so much dude, that is an awesome script, i love it, i figured it out , i took out the second part because it was giving so many errors, but it works great i figured it out... THX you rock

                            just incase u have time, can u please explain to me every line of what the Second part of your script means?? if u can please?

                              now i did the same exact thing to another website, buit this time i have thumbnails

                              after hours of wth is going on...

                              i have the original script
                              and when i press next
                              it doesnt go next!!!!

                              whY?

                              none of it works...
                              Click here for example

                              the other one is the same but with 1 image in each page, and
                              the thumbnails and the images folder is the same (becuase i didnt have thumbnails)

                              now i do but the link above shows that it doesnt work

                                Originally posted by Dax
                                just incase u have time, can u please explain to me every line of what the Second part of your script means?? if u can please?

                                i'll see if i got time later, yeah.

                                what kind of errors was it giving you?

                                works for me 😕

                                okay, just saw your newest post...

                                i don't know why it would do differently on a different server, more then likely tho, ti's the PHP settings.

                                that page you linked me too, didn't like loading (timed out)

                                  Dax.. it would help if you can tell us wether your server has a GD or not.. and what version it is currently.

                                  On the Other Side..

                                  heyy mike.. how is it going..
                                  Happy nu year to you mate..!!
                                  haven't heard from ya for quite a while..
                                  still remember you here first time asking about some login script
                                  for you car site.. :p
                                  take care mate..!!

                                    i dont know...speaking of php settings...

                                    i just remembered somthing....
                                    in that website like 3 months ago i made a uploading admin type thing and it was wierd whenever i linked to the .php file it kept booting me back to index.htm

                                    i dunno what GD is..
                                    but i think PHP is disabled somehow in the server

                                      Originally posted by jassh
                                      Dax.. it would help if you can tell us wether your server has a GD or not.. and what version it is currently.

                                      On the Other Side..

                                      heyy mike.. how is it going..
                                      Happy nu year to you mate..!!
                                      haven't heard from ya for quite a while..
                                      still remember you here first time asking about some login script
                                      for you car site.. :p
                                      take care mate..!!


                                      Haha, yeah that was me. That site's doing very well, as well most of my other sites 🙂

                                      http://www.tunercarz.com <- the product today 🙂

                                      as for your php settings...

                                      do this make a page and just put this in it

                                      <?
                                      phpinfo();
                                      ?>
                                      

                                      then upload it adn link us to it, that will tell us all your php settings, including your GD settings 🙂

                                        Write a Reply...