baby83 Posted July 23, 2008 Share Posted July 23, 2008 i have 2 tables in my database. which are 'personal' and 'education'. both hav 'identity_number' field. first, i fill the personal form. and the 'identity_number' will automatically insert into both tables. but when i want to fill the education form, the data didnt update the existing data but inserted into the next row. how can i call the 'identity_number' from 'education' and update it? btw, the education form need to be fill again if the user have more than one... can u help me? i'm not really good in php and sql... but i really want to do this... please... Quote Link to comment https://forums.phpfreaks.com/topic/116222-how-to-insert-the-same-data-into-2-tables/ Share on other sites More sharing options...
revraz Posted July 23, 2008 Share Posted July 23, 2008 So are you asking how to get the last inserted ID? Is it autoincrement or do you set it? Quote Link to comment https://forums.phpfreaks.com/topic/116222-how-to-insert-the-same-data-into-2-tables/#findComment-597621 Share on other sites More sharing options...
.josh Posted July 23, 2008 Share Posted July 23, 2008 You're going to have to be a bit more specific, and also show us some code. I think you're saying you have two tables and you want them both to hold the same info, so if someone has never filled out either of the forms, it will insert the info into both tables, but if someone has filled out one but not the other, it only inserts into one table? If that is what you're saying, then I think you're going about this all wrong. First off, why do you need two different tables that hold the exact same information? And if for some reason you just *need* to have two tables with the same information (which seriously, I can't think of a reason why you would), just have it insert the data into both tables no matter which form is filled out, to begin with. That solves the whole "if one filled but not the other" scenario...unless you have "grandfathered" people already in one or the other table and your making this whole new system and you want to be able to accommodate that. But if that's what you are doing, why not just force everybody to refill one of it out? Problem solved. Or just make a quick script to copy the info from 1 to the other - problem solved. As far as this: the education form need to be fill again if the user have more than one... Again, we aren't in your situation, so that doesn't really mean a whole lot to us. You're going to have to get a lot more detailed about your question and situation. Quote Link to comment https://forums.phpfreaks.com/topic/116222-how-to-insert-the-same-data-into-2-tables/#findComment-597642 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.