phs2911 Posted January 14, 2010 Share Posted January 14, 2010 Okay, maybe it's late but I'm scratching my head over this one. I have a MySQL table that has data like this: prior_status current_status inactive active inactive active inactive inactive inactive active inactive inactive I'm trying to figure a way to transcribe the columns (from current_status TO prior_status) using PHP. In other words, I want to replace the "prior_status" with whatever the "current_status" is, so I can then change all the "current_status" entries to inactive and thus have a club membership status history. I'm sorta at a loss here, for several reasons: 1. I'm not sure how many db entries I could have. I could have just 5 lines, or I could have 50. I'd like the PHP code to loop until it finds no more db entries. 2. I know how to SELECT or UPDATE an entry, but it seems here that I need to do both simultaneously. Can I do that, or do I need some sort of array? I successfully did this a few years back, but I misplaced that file, and I can't for the life of me remember how I did it. Any help would be greatly appreciated!!! Quote Link to comment https://forums.phpfreaks.com/topic/188427-transcribe-mysql-fields-with-php/ Share on other sites More sharing options...
kickstart Posted January 14, 2010 Share Posted January 14, 2010 Hi Why do you need to do it in a php structure / loop? If you want to update the prior_status UPDATE sometable SET prior_status = current_status WHERE someclause All the best Keith Quote Link to comment https://forums.phpfreaks.com/topic/188427-transcribe-mysql-fields-with-php/#findComment-994782 Share on other sites More sharing options...
phs2911 Posted January 14, 2010 Author Share Posted January 14, 2010 Thanks for the solution, Keith!! I need to do it in a php loop because I'm crazy and didn't see the obvious simple solution. Like when you temporarily can't recall your wife's name after being married for 8 years. What? That only happens to me?! Thanks again! Quote Link to comment https://forums.phpfreaks.com/topic/188427-transcribe-mysql-fields-with-php/#findComment-994927 Share on other sites More sharing options...
kickstart Posted January 14, 2010 Share Posted January 14, 2010 Hi Wait until you forget your own name. All the best Keith Quote Link to comment https://forums.phpfreaks.com/topic/188427-transcribe-mysql-fields-with-php/#findComment-994958 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.