0

I'm currently working on a little gallery, which can be edited by many users. I have an upload function - so people can add photos to the gallery - and I have a database, to which people can manually add information about the images. However, I want this process to work automatically, so that, when they add a photo called sunset.jpg, it immediately adds the information (i.e. Name: Sunset; Source: sunsetpix.com/sunset1; Size: 200 MB) to the MySQL database.

My current code for adding information to the MySQL database is this:

$sql = "INSERT INTO Image_table (ID, Name, FilePath) VALUES (NULL, 'NameExample', 'SourceExample')";

What do I need to change to automate this process?

Zetland
  • 569
  • 2
  • 11
  • 25
  • What did you search for and what have you tried? There are many results to be found related to what you wish to achieve. If the answer is *"I didn't look, and haven't tried anything",* then this is a code request; considered to be off-topic on Stack and frowned upon by many. – Funk Forty Niner Dec 05 '14 at 15:41
  • Could you send me a few links. I've tried a few searches along the lines of "how to automatically add image data to a mysql database" but nothing particularly useful came up. – Zetland Dec 05 '14 at 15:44
  • Google "upload file and add to database php" and you will see many links. Many of which leading you back here on Stack with answers you can base yourself on. PHP/SQL doesn't "automatically" do the work, you need to tell it what to do, as in "write the code" for it; only then will it "automatically" do the work ;) – Funk Forty Niner Dec 05 '14 at 15:45
  • Oh yeah, I get that. I just wanted to build the door that the data can walk through. Thanks! – Zetland Dec 05 '14 at 15:51
  • You're welcome. If you did Google those keywords I gave you, the second result should have been http://stackoverflow.com/q/17153624/ - Yet, it's `mysql_` based, but you can easily convert that to `mysqli_` or PDO. – Funk Forty Niner Dec 05 '14 at 15:54

0 Answers0