Question

I'm creating form for multiple photos to be uploaded and i want create a directory which is named as the id of the table, the id should be the present id in which the form will be uploaded , in sort i want the current id of the table of database

Was it helpful?

Solution

Your question is not that clear, so let me phrase what I think is going on, and correct me where I have misinterpret you.

You have a table that stores information about photos. The table has an ID column with auto_increment set. Whenever you insert something into the database, you want to retreive this ID so you can create a folder to store your photos in. Correct?

Basically, execute your query, which would be something like:

INSERT INTO `myTable` SET `name`="Name of photo", `filename`="photo.png"

then do the following:

$last_id = mysql_insert_id();

or if you are using mysqli:

$last_id = mysqli_insert_id();

With this $last_id you can now make a folder etc...

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top