phpleh
November 12, 2007 1:42 PM   RSS feed for this thread Subscribe

help with php and pulling images from a database and posting them to a website.

I'm no whiz at PHP but I used to know Cold Fusion (back in the days) so I can pick it up pretty quickly.

I'm looking for this (as best as I can spell it out):

I upload my images to a directory
php queries the database and generates a page for each image
navigation buttons are below that work as vcr buttons on each page

I don't know how to search for that as I don't know the right term I'm looking for. Could someone help me out?
posted by Hands of Manos to computers & internet (9 comments total)
for an example, basically I want to be able to do this:
http://www.userfriendly.org

just with my images
posted by Hands of Manos at 1:45 PM on November 12, 2007


This is how I did something similar

//create a php form for uploading the files to your directory...

//on upload, put the file name into a MySQL table.. It could have to columns the first is an id number used as the primary key and the second is the file name. I would also throw in a title for each image (for use in an archive)

//create a single page that takes in a GET variable... That Get variable is the id number of the pic to load
//the page takes the get variable, queries the database and loads the image
//query the database for the id before and after that image, along with the first and last id in the database.
//each of your vcr links is a link back to this page with the get variable set to the ID you want.

//While you're at it, create an archive page that queries the database and then creates links back to the page above with the variable set to the images ID entry.
posted by drezdn at 2:02 PM on November 12, 2007 [2 favorites]


nest the image tags inside an anchor?
posted by zorro astor at 2:03 PM on November 12, 2007


You'll probably want to password protect the form and such, and there's probably a few steps I skipped. I did something similar though, and if you want, I could send you the code for it.
posted by drezdn at 2:03 PM on November 12, 2007


It seems that the database is unnecessary, and that you could just generate this based on a naming convention of files.

Even if you have metadata (eg, the comics title) you could go a long way without needing a database for this. Just name your image files 1--my-first-comic.jpg, 2--my-second-comic.jpg and so on.

It's tempting to overengineer this but so far I haven't seen any need for a database.
posted by holloway at 2:33 PM on November 12, 2007


Holloway is right, I like adding the database for alt text and title text.
posted by drezdn at 2:42 PM on November 12, 2007


you still dont technically need a database. when you name the picture. write a text file with the same name and write in it any other bits of info you want on separate lines. as long as you keep to conventions within these files it'll work.
posted by browolf at 4:16 PM on November 12, 2007


Aren't you basically looking for an image gallery script? There's lots of them. Here's a Google search to get you started.
posted by evariste at 4:19 PM on November 12, 2007


Seconding the don't need a database opinion, if you don't need lots of metadata. I have done something similar in the past just by structuring the file hierarchy properly, with judicious use of text files for minimal file information like human-readable titles etc. However, you need to be extra defensive when coding your page, as the data structure can get incoherent quite easily.
posted by the number 17 at 11:31 PM on November 12, 2007


« Older Looking for [ IT | data center...   |   Does anybody know of any decen... Newer »
This thread is closed to new comments.


Related Questions
Getting Google Images results via PHP? August 11, 2008
A little bigger than a thumbnail February 13, 2008
Saving an image with the imagejpeg() function October 12, 2007
Light-weight image browser? May 26, 2006
how to display image files on a web page January 26, 2005