Jump to content

Archived

This topic is now archived and is closed to further replies.

hlstriker

PHP and MySQL help please?!

Recommended Posts

Hey I have a quick question. I am trying to make a page that users can sign up, then later on add things of what they have to sell. Would I need to give each user their own table for this, or could I somehow do it with 1 table?

For example: User "Ned" signs up, then he later on adds things to sell (which would go into a field).

There will be multiple users, that's why I wondered if I had to make more then 1 table, since I don't know if there could be multiple item's in 1 field?

Share this post


Link to post
Share on other sites
Two tables - one for users, the other for items for sale

table 1: user_id, username, password, email, whatever else - one record per user
table 2: id, user_id, item_for_sale,price, whatever else - one record per item for sale

Share this post


Link to post
Share on other sites
[quote author=AndyB link=topic=102022.msg404360#msg404360 date=1153972828]
Two tables - one for users, the other for items for sale

table 1: user_id, username, password, email, whatever else - one record per user
table 2: id, user_id, item_for_sale,price, whatever else - one record per item for sale
[/quote]


Is id in table 2 a primary key? If so, what if a user_id has many things to sell? Shouldn't there be just a table that list just the unique item for sell?

Share this post


Link to post
Share on other sites
user_id is primary key for 1st table
and id for second table
if a user inputs multiple items , those will be saved to second table against same user_id
so while fetching,
fetch all rows and create table or something like that.....

Share this post


Link to post
Share on other sites

×

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.