Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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