I need help with my gallery script.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

pepsidemon
Forum Newbie
Posts: 13
Joined: Sun Apr 04, 2004 10:21 pm

I need help with my gallery script.

Post 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.

Last edited by pepsidemon on Mon Apr 05, 2004 1:39 pm, edited 1 time in total.
pepsidemon
Forum Newbie
Posts: 13
Joined: Sun Apr 04, 2004 10:21 pm

Post 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 :(
Paddy
Forum Contributor
Posts: 244
Joined: Wed Jun 11, 2003 8:16 pm
Location: Hobart, Tas, Aussie
Contact:

Post 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?
pepsidemon
Forum Newbie
Posts: 13
Joined: Sun Apr 04, 2004 10:21 pm

Post 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.
Paddy
Forum Contributor
Posts: 244
Joined: Wed Jun 11, 2003 8:16 pm
Location: Hobart, Tas, Aussie
Contact:

Post by Paddy »

Oops, misread. Apologies.
pepsidemon
Forum Newbie
Posts: 13
Joined: Sun Apr 04, 2004 10:21 pm

Post by pepsidemon »

That's ok,heh.
pepsidemon
Forum Newbie
Posts: 13
Joined: Sun Apr 04, 2004 10:21 pm

Post by pepsidemon »

I'm never gonna figure this out :cry:
User avatar
andre_c
Forum Contributor
Posts: 412
Joined: Sun Feb 29, 2004 6:49 pm
Location: Salt Lake City, Utah

Post 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

?>
magicrobotmonkey
Forum Regular
Posts: 888
Joined: Sun Mar 21, 2004 1:09 pm
Location: Cambridge, MA

Post by magicrobotmonkey »

I'm not sure exactly what the problem is
pepsidemon
Forum Newbie
Posts: 13
Joined: Sun Apr 04, 2004 10:21 pm

Post 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.
pepsidemon
Forum Newbie
Posts: 13
Joined: Sun Apr 04, 2004 10:21 pm

Post by pepsidemon »

...
pepsidemon
Forum Newbie
Posts: 13
Joined: Sun Apr 04, 2004 10:21 pm

Post 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.
User avatar
johnperkins21
Forum Contributor
Posts: 140
Joined: Mon Oct 27, 2003 4:57 pm

Post 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/
pepsidemon
Forum Newbie
Posts: 13
Joined: Sun Apr 04, 2004 10:21 pm

Post by pepsidemon »

i found one,but don't know how to use it w/ my script.
pepsidemon
Forum Newbie
Posts: 13
Joined: Sun Apr 04, 2004 10:21 pm

Post by pepsidemon »

i really need help with this.it's so hard to figure stuff out,lol.
Post Reply