/    Sign up×
Community /Pin to ProfileBookmark

Just started breaking into MySQL as suggested by so many people on this site. And it’s going pretty well…

My question, or more a “which direction should I head?” Is with regards to my image galleries. Until now… My website has been purely Static and Purely HTML. What it is, is that people email me images, I add my logo and then using FTP, upload the images onto the server. Before doing this, however… I have to Physically create an HTML file for each image. As you can well imagine, and I’m sure, have experienced back when you started, this could be really really time consuming and tedious work, aswell as span a few hours.

I am wanting to add more Automation to the process. Maybe… Manually editing the images (I Use FireWorks Batch processing for that, so literally takes 5 mintues) Then just uploading them, somehow, with something like:

IMG SRC=”3957.jpg” ID=”My car” DESCRIPTION=”This is the new car I bought”

into a DataBase, or dropping them into a folder and having PHP read the files… I’m not 100% sure how to do this.

From what I can gather from some other sites with Galleries, they put all the files into one folder, then have a next and previous button. So it sifts through the images, in order. I am assuming some sort of ID is attached, and PHP just uses ++ and — to go through the folders contents.

If this is the case, how would you get the image title and description displayed???

Am really lost as to where to begin. So if someone could please offer a direction or guideline… It would be greatly apprecriated and I could get to work on it ASAP!

?

to post a comment
PHP

12 Comments(s)

Copy linkTweet thisAlerts:
@MindzaiAug 14.2009 — Given that one of your requirements is the display of image metadata, for example a description, just scanning a folder's contents wont be sufficient. As you say, whilst that is a simple way to display a load of images, you cannot associate extra data with each file.

That is where a database comes in. You can create a table named 'images' (or whatever) with a unique primary key field as well as a field for filename plus fields for any extra data you want to display.

You would then query the database for an image and its data, and display it as required.

This is also very flexible. If you want to display 1, 10 or 100 images per page, it's easy to do and you wont need loads of separate HTML files.
Copy linkTweet thisAlerts:
@Hooded_VillianauthorAug 14.2009 — Given that one of your requirements is the display of image metadata, for example a description, just scanning a folder's contents wont be sufficient. As you say, whilst that is a simple way to display a load of images, you cannot associate extra data with each file.

That is where a database comes in. You can create a table named 'images' (or whatever) with a unique primary key field as well as a field for filename plus fields for any extra data you want to display.

You would then query the database for an image and its data, and display it as required.

This is also very flexible. If you want to display 1, 10 or 100 images per page, it's easy to do and you wont need loads of separate HTML files.[/QUOTE]


You guys talking me into MySQL was the best arm twist ever...

So... Create a DB, then have fields like ID, File_Name, Description etc... If Description == NULL; echo "No Description"; etc. Then with the Next and Previous Button, it would just use the ID with Increments and Decrements.

I like it...

Thats one of the main things aswell... I could use ONE html file per MONTH (IE: Jan, Feb etc...) That calls up the images for that Month. As with the Adverts and side bar images, that is what JavaScript is for. Click Refresh or Next/Previous, Content is reloaded. Hmmm... Starting to get an idea.
Copy linkTweet thisAlerts:
@SyCoAug 14.2009 — 
So... Create a DB, then have fields like ID, File_Name, Description etc... If Description == NULL; echo "No Description"; etc. Then with the Next and Previous Button, it would just use the ID with Increments and Decrements.[/QUOTE]


Not quite. You might delete a record which leaves holes in the id list. Really if you want to show a prev and next links, you need to grab 3 records and show the middle one and link the id from the prev and next records. Of course you need to think about the first and last image too as they wont have a prev or next ids (respectively).
Copy linkTweet thisAlerts:
@Hooded_VillianauthorAug 21.2009 — Ok... Internet back up and running. And back to my MySQL education.

So... How would I make it, that the uploading of the images were automated, as such. IE: They get sent to my email, I take em, slap on a logo, then upload them using FTP. But... where does the ease and automation of DataBases and PHP come into it???
Copy linkTweet thisAlerts:
@MindzaiAug 21.2009 — where does the ease and automation of DataBases and PHP come into it??? [/quote]

For one thing you could automate everything you currently do.
Copy linkTweet thisAlerts:
@Hooded_VillianauthorAug 21.2009 — For one thing you could automate everything you currently do.[/QUOTE]

But that must be some serious Advanced PHP/MySQL... I am how you say... a NOOB. lol.

Where would I even start???

update. Well... One or two things I have done is made my title and footer dates auto using the date(); function. I have also created an include('footer.php')
Copy linkTweet thisAlerts:
@SyCoAug 25.2009 — Personally I wouldn't even mess with email. The users (or yourself) can upload the images via a web form, you can add a logo during the upload process with GD and add the image to a moderate list. You then log into your site and view newly uploaded images and accept or reject.

Lots of tutorials already out there for securely uploading images. Then google adding a watermark with GD which will slot into the upload process. The mod list is just a simple flag column where you flip a yes/no value. When the image is uploaded, you have a column called something liked 'accepted' set by default to 0 and when you accept it you flip the value to 1. Anywhere else on your site you only select images in your SQL statements where the value is 1.
Copy linkTweet thisAlerts:
@Hooded_VillianauthorSep 06.2009 — Personally I wouldn't even mess with email. The users (or yourself) can upload the images via a web form, you can add a logo during the upload process with GD and add the image to a moderate list. You then log into your site and view newly uploaded images and accept or reject.

Lots of tutorials already out there for securely uploading images. Then google adding a watermark with GD which will slot into the upload process. The mod list is just a simple flag column where you flip a yes/no value. When the image is uploaded, you have a column called something liked 'accepted' set by default to 0 and when you accept it you flip the value to 1. Anywhere else on your site you only select images in your SQL statements where the value is 1.[/QUOTE]


Right... I agree with all you've said. I have a book HeadFirst into PHP and MySQL that I am studying from and it seems to show me how to do most of what you said.

Question: My site is dedicated to images and videos sent in by visitors directly from their Mobile phones and PDA devices, using email or MMS. Hence the use of an email address... Is there a way around this?
Copy linkTweet thisAlerts:
@opifexSep 06.2009 — Just a suggestion....

If you are really inexperienced, it might be worth taking a look at one of the various Open Source galleries like Coppermine Gallery (http://coppermine-gallery.net/). It will handle your image and video galleries out of the box and you can modify it as needed.

Sometimes hacking on something that already works is helpful when learning new things!?
Copy linkTweet thisAlerts:
@Hooded_VillianauthorSep 06.2009 — Just a suggestion....

If you are really inexperienced, it might be worth taking a look at one of the various Open Source galleries like Coppermine Gallery (http://coppermine-gallery.net/). It will handle your image and video galleries out of the box and you can modify it as needed.

Sometimes hacking on something that already works is helpful when learning new things!?[/QUOTE]


I will look into that.. Thanks alot :-)
Copy linkTweet thisAlerts:
@Hooded_VillianauthorMar 05.2010 — Aren't there php email functions to download email messages from the server, to my own "user created" page where it loops through & I can click, DENY/UPLOAD... Then upon wither choice it will run a MySQL query, delete * from or insert into...

Think I saw something along the lines of http_imap_header() or something...
Copy linkTweet thisAlerts:
@SyCoMar 05.2010 — yep,

http://us3.php.net/manual/en/book.imap.php

That was quite the break in this thread, lol!
×

Success!

Help @Hooded_Villian spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.5,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...