Reputation: 4033
Im wondering if someone could help me out with a little issue im having.
I have some code which enables a user to click a button and it will create a additional file input box ... The amount of times they can click this is unlimited, so realisticly they can add unlimited images to their profile.
The problem im having is im not sure how to go about saving that information to the database, usually i would add a row for a file input and store the name, but as there can be unlimited amounts of filenames, im not sure how i would go about saving it.
Could anyone out there give me some suggestions on how they would do it?
Thanks
Upvotes: 1
Views: 577
Reputation: 21957
Usually it's doing using 2 tables and foreign keys. One table with users(user) (id, name, ...). Second table with photos of users(user_photo) (id, user_id, photo_path, ...). Foreign key will be created between user.id and user_photo.user_id with cascade delete/update.
Upvotes: 0
Reputation: 1512
I would store additional pieces of information in a separate table. It only needs 2 fields, data
and user_id
, Then for each additional input, you would store the data
and the user's unique user_id
. To retrieve the data, just filter using the user_id
.
Upvotes: 3