Jump to content

php mysql one to many relationship or something else?


Recommended Posts

I am trying to figure out what to do from here. I am using mysql for my database. 

In my form from mysql I wish to have the possibility for people to upload from 1 to many images that can be queried along with the data submitted in the form. I am not asking for someone to write me the code, but to point me in the right direction of what type of solution I can use or what I can read on to learn to get this done.

 

User example here:

1. a registered user is filling out a form for example a car for sale ad.

2. user wishes to upload images relating to that car sale ad. 

3.if the user fills out the car for sale form and clicks submit/next.How to display the form the user just clicked submit in the next page to appear,so the user can add images there/here?

 

I hope someone can point me in the right direction or can give me their input on what else I can read on to do this.

 

 

Thank you in advance

 

Once the user begins the process by submitting the form and you save that info with an "id", you simply put out a form for the user to then submit images to be uploaded.  Store those images in a folder with a table that relates each image file name to the "id" in a separate table.

 

User table with id links to

image table with id and image file name

 

Store all images in one folder and always look in that folder for the image file name.  Probably want to include the user "id" as a prefix to the image file name to ensure uniqueness.  When you do a query you simply join the two tables together.

 

You don't want to store the images themselves in a table - wasteful.  Simply define a folder and just save the filename. 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.