i am using the jQuery Plugin Uploadify to upload files, and i store the image name with path into the database with simple mysql query and then retrieve it.
my MySQL database table is using the following entities,
id int(20)
image_url varchar(255)
my image store procedure is such as, i first rename the file, give it a unique name and move it to the desired directory. and then store the image name with path into the database.
currently by using simple mysql INSERT statement i am storing a single file name.
now i want to upload the array of image names with path. or i want to store as much image as i want dynamically into the single table col image_url, for some reason i plan to store 4 or more images, i want all the four image to have one particular id number.
how do i do it?
thank you
Edit 2
I removed the previous scripts, here’s a new one:
Best way to do this is to add a separate entry for each image url. You can also use a single entry and store all the urls as an array, but since you’re storing this in a database that isn’t very useful. Storing each entry separately makes it a lot easier to access and update the data.
Also, make sure the “id” field in your table isn’t a primary key / auto incrementing. Otherwise you won’t be able to use the same id more than once. I fixed that here:
If you do want to store arrays, it’s best to
serializethe data and useunserializewhen you retrieve it. Example:To add images, you should then first retrieve the data, unserialize the array, update the array with the new images, serialize it again, update the database entry.