Jump to content

Help with relationship between 2 tables


TCombs

Recommended Posts

I have a table for logins and a table for addresses.

 

I'm using 1 form to create the username/password (which is being inserted into the "logins" database), and the persons name, address, etc. which is being inserted into the "addresses" database.

 

What do I need to do to make it so that when a user log's in to the site and make's it to the checkout page, that their address is tied to their username?

 

 

Link to comment
https://forums.phpfreaks.com/topic/233232-help-with-relationship-between-2-tables/
Share on other sites

Make a UNIQUE/AUTO_INCREMENT field called something like `user_id` to your `logins` table to identify your users uniquely. Then add a field to your `addresses` table which identifies the id of the user that the address belongs to.

 

Then you can call on the address easily:

SELECT address from addresses WHERE user_id = $id

Archived

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

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