TCombs Posted April 9, 2011 Share Posted April 9, 2011 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? Quote Link to comment https://forums.phpfreaks.com/topic/233232-help-with-relationship-between-2-tables/ Share on other sites More sharing options...
dcro2 Posted April 9, 2011 Share Posted April 9, 2011 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 Quote Link to comment https://forums.phpfreaks.com/topic/233232-help-with-relationship-between-2-tables/#findComment-1199480 Share on other sites More sharing options...
TCombs Posted April 9, 2011 Author Share Posted April 9, 2011 lol my apologies, yes, I meant table...not database. dcro2...thanks for responding again! You're a much trusted resource. I'll give your advice a try and let you know how it turns out! Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/233232-help-with-relationship-between-2-tables/#findComment-1199482 Share on other sites More sharing options...
TCombs Posted April 12, 2011 Author Share Posted April 12, 2011 DCRO2..... Thanks again! Everything is working now. You're an asset to these forums! Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/233232-help-with-relationship-between-2-tables/#findComment-1200357 Share on other sites More sharing options...
dcro2 Posted April 12, 2011 Share Posted April 12, 2011 Any time, ha. Glad to help. Quote Link to comment https://forums.phpfreaks.com/topic/233232-help-with-relationship-between-2-tables/#findComment-1200358 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.