Page 1 of 2

I need help with my gallery script.

Posted: Sun Apr 04, 2004 10:21 pm
by pepsidemon
Hello,I am trying to create a gallery.I have successfully created most of the basic things.I just need help with an aspect or two.I have been trying to put something like this in the script for paging:
<<first|1|2|3|4|5..lats>>
something like that or even relative.
and also something that organizes it by date or name.
I have only found tutorials on this using sql.I am not using sql for the gallery.I have downloaded a script with something similar to what I need.I wanted to put that part into my script and buld up on it.

Here is the part of my script I need it to be integrated into:

Code: Select all

<?php for ($i=1; file_exists("images/image".($i).".jpg"); $i++) {
$a=getimagesize("images/image".($i).".jpg");
$i=($i);
echo "<td width="".($a[0]).""><a href=preview.php?i=$i target=pre><img border=0 width=100 height=100 src=images/image$i.jpg></a></td>";
} 

?>
If you have a solution and can write it up here,that would be a HUGE help.

But if you need the other script,I will post that.


Posted: Sun Apr 04, 2004 10:35 pm
by pepsidemon
I was on the comp for 8 hours trying to figure this out...I still don't know it.I'm so stupid :(

Posted: Sun Apr 04, 2004 10:44 pm
by Paddy
Just as a quick question. you don't have image001.jpg rather than image1.jpg?

And as a debug comment out the code in the middle and see if it does an echo. At least then you will know if the loop is being entered. Do you get an echo at all when you run the script?

Posted: Sun Apr 04, 2004 10:47 pm
by pepsidemon
When I run the script i just posted it works normally.The pic is seen as image1.jpg or image2.jpg,etc.The when you click the thumbnail it goes to the full image.

Posted: Sun Apr 04, 2004 10:49 pm
by Paddy
Oops, misread. Apologies.

Posted: Sun Apr 04, 2004 10:57 pm
by pepsidemon
That's ok,heh.

Posted: Sun Apr 04, 2004 11:33 pm
by pepsidemon
I'm never gonna figure this out :cry:

Posted: Mon Apr 05, 2004 1:28 am
by andre_c
Hope this helps...
It uses a while loop instead of a for loop, which is much better if you don't know how many images you'll have

Code: Select all

<?
$dir = '/dir/to/images';

$counter=0;
if (is_dir($dir)) {
  if ($dh = opendir($dir)) {
    while (($file = readdir($dh)) !== false) {
      if ($file!="." && $file!=".." && $file!="Thumbs.db") {
        $pictures_array[$counter] = $file;   // save pic names to array
      }
    }
  }
  closedir($dh);
}

// save array to session array
// you can also sort this array by name or date before you display them
$_SESSION['pics'] = $pictures_array;


// save last picture displayed to the session too for pagination
// and use that to know how many to display on each page

?>

Posted: Mon Apr 05, 2004 7:04 am
by magicrobotmonkey
I'm not sure exactly what the problem is

Posted: Mon Apr 05, 2004 1:38 pm
by pepsidemon
I wanted to limit the amount of images i have per page.I just don't know how to do it and put it into my script.

Posted: Mon Apr 05, 2004 2:04 pm
by pepsidemon
...

Posted: Mon Apr 05, 2004 2:17 pm
by pepsidemon
i should explain better.

this is what i'm having trouble with.
Say I have 20 images.and I only want to display 5 images on each page.If there are the 20 images and only a limit of 5 per page,it will make it to where it numbers the next few pages.

Posted: Mon Apr 05, 2004 3:55 pm
by johnperkins21
There are quite a few of these on hotscripts. If you download one and look at the code, it should get you through it.

http://www.hotscripts.com/PHP/Scripts_a ... Galleries/

Posted: Mon Apr 05, 2004 4:28 pm
by pepsidemon
i found one,but don't know how to use it w/ my script.

Posted: Mon Apr 05, 2004 9:48 pm
by pepsidemon
i really need help with this.it's so hard to figure stuff out,lol.