LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 12-19-2005, 02:01 PM   #1
drspin
LQ Newbie
 
Registered: Dec 2005
Posts: 11

Rep: Reputation: 0
PHP image gallery


I'm trying to use PHP to build a dynamic image gallery. The files are organized on the filesystem how I want them viewed on the page. It would be nice if changes to the files would yield changes on the page (like a database). I looked around a bit on google and other sites (PHP) and can't find anything that demonstrates a straight forward way to do this.

On the site the user would see:

2004
> Tall Pictures
> Wide Pictures

2005
> Tall Pictures
> Wide Pictures

2006
> Tall Pictures
> Wide Pictures

The filesystem is like this:

2004/tall/<image>
2004/wide/<image>

2005/tall/<image>
2005/wide/<image>

2006/tall/<image>
2006/wide/<image>


I'm sure this is fairly easy but after a few days of searching... nothing... If you can point me to a tutorial or an application that does this or somewhere that might at least have an example of this I would greatly appreciate it.


Cheers!
Cole
 
Old 12-19-2005, 02:17 PM   #2
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
For whatever it's worth, "Gallery" is an excellent open-source alternative (our Church/school is successfully using it), if you don't want to re-invent the wheel:

http://gallery.menalto.com/
 
Old 12-19-2005, 08:16 PM   #3
drspin
LQ Newbie
 
Registered: Dec 2005
Posts: 11

Original Poster
Rep: Reputation: 0
I got it working -- here's how

<?php
$type=$_GET['type']; // get type from the address bar
$year=$_GET['year']; // get year from the address bar
$base="pictures"; // sets the base folder for the script

$directory=$base . "/" . $year . "/" . $type."/"; // put em together
$thumbsdir=$directory ."thumbs/";

$mydir = dir($directory); // open the directory for reading

while(($file = $mydir->read()) !== false) {

if(is_dir($mydir->path.$file)) { continue; } // if it's a folder, do nothing and continue the loop

else { echo "<a href=" . $directory . $file . "><img src=" . $thumbsdir . $file . " border=1></a>";} // otherwise show the thumbnail and link to the picture
}

$mydir->close(); // close the folder
?>


I would like to note that the code is rough and so is the solution but it serves it's purpose for the time being.

Thanks for the assistance.
Cole

Last edited by drspin; 12-19-2005 at 08:18 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Apache2, PHP and Gallery problem itamarl Linux - Software 6 04-05-2005 01:36 AM
Web-access image gallery software? gypsy_rabbi Linux - Software 2 09-17-2004 11:48 AM
Specific Image Gallery eggoz Linux - Software 1 08-31-2004 07:46 PM
photo gallery that will work in php safemode also ehpserver Linux - Software 0 10-09-2003 07:22 PM
creating an image gallery meluser Linux - Software 1 07-22-2003 03:19 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:37 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration