itgranny Posted September 22, 2015 Share Posted September 22, 2015 I have 2 tables. One with site names and usernames, the other with data that needs to be entered from a form. The form has a dropdown list of the site names for the user to fill out. What I would like is for the form to automatically get the username and place it in the data table also, automatically. ID siteName userName 1 Site 1 site1 2 Site 2 site2 3 Site3 site3 Form has dropdown is populated with siteName from the site table. User picks one (along with other data but that's working). Submit Posted to insert page Insert page sees the siteName I want it to go to into site table and look for whatever site they chose and figure out what the userName it insert it into the username place in the data table that the form is updating. How would I go about doing this? I've tried a bunch of different ways but keep getting errors. Quote Link to comment https://forums.phpfreaks.com/topic/298273-single-entry-based-on-another/ Share on other sites More sharing options...
mac_gyver Posted September 22, 2015 Share Posted September 22, 2015 your form should submit the id and you should store the id in the second table to relate the row in the second table back to the source information in the first table. information like the sitename/username should only exist once, in the source table where it is defined/stored. Quote Link to comment https://forums.phpfreaks.com/topic/298273-single-entry-based-on-another/#findComment-1521353 Share on other sites More sharing options...
Barand Posted September 22, 2015 Share Posted September 22, 2015 What I would like is for the form to automatically get the username ... ... and figure out what the userName it Are you invoking magic or do you have a more mundane method of storing and acquiring the username? Quote Link to comment https://forums.phpfreaks.com/topic/298273-single-entry-based-on-another/#findComment-1521354 Share on other sites More sharing options...
itgranny Posted September 22, 2015 Author Share Posted September 22, 2015 So is it Ajax that you get the username right away from the form or are you saying I need to put an addional dropdown that they have to fill out? Quote Link to comment https://forums.phpfreaks.com/topic/298273-single-entry-based-on-another/#findComment-1521356 Share on other sites More sharing options...
benanamen Posted September 25, 2015 Share Posted September 25, 2015 Sounds like your DB structure is not right. Post your DB schema for us to review. Quote Link to comment https://forums.phpfreaks.com/topic/298273-single-entry-based-on-another/#findComment-1521495 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.