Jump to content


Photo

PHP and MySQL help please?!


  • Please log in to reply
5 replies to this topic

#1 hlstriker

hlstriker
  • Members
  • PipPipPip
  • Advanced Member
  • 84 posts

Posted 27 July 2006 - 03:51 AM

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?

#2 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 27 July 2006 - 04:00 AM

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
Legend has it that reading the manual never killed anyone.
My site

#3 hlstriker

hlstriker
  • Members
  • PipPipPip
  • Advanced Member
  • 84 posts

Posted 27 July 2006 - 04:05 AM

Thanks alot AndyB!  :D

#4 extrovertive

extrovertive
  • Members
  • PipPipPip
  • Advanced Member
  • 235 posts

Posted 27 July 2006 - 05:47 AM

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



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?


#5 sonal4php

sonal4php
  • Members
  • Pip
  • Newbie
  • 7 posts

Posted 27 July 2006 - 10:05 AM

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.....

#6 extrovertive

extrovertive
  • Members
  • PipPipPip
  • Advanced Member
  • 235 posts

Posted 27 July 2006 - 06:45 PM

Ah I see now.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users