> Note how the ID number does NOT go in a sequence with the owner.
OK, as a rule your owner field would be an integer linked to a 'users' table and the itemname would also be an integer linked to an 'items' table. So your resulting table would be what's commonly called a 'link table'.
users
user_id | name | (other fields pertaining to the user, e.g. password, email etc)
items
item_id | itemname | (other fields pertaining to the item)
useritems (the link table)
item_id | user_id
Your logged in user (usually identified by a session variable, e.g. user_id: $_SESSION['user_id']) can then view their items thus:
$user_id = $_SESSION['user_id'];
$rs = mysql_query("SELECT i.item_id, i.itemname FROM items AS i ON useritems AS ui INNER JOIN i.item_id = ui.item_id WHERE ui.user_id = $user_id");
I've used aliases (AS) above - they cut down on having to name the full table as a prefix every time.
diafol
Rhod Gilbert Fan (ardav)
Moderator
7,796 posts since Oct 2006
Reputation Points: 1,170
Solved Threads: 1,080