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 Share on other sites More sharing options...
Psycho Posted January 14, 2010 Share Posted January 14, 2010 Just do the whole table in a single query. No mess, no fuss: UPDATE table SET prior_status = current_status, current_status = 'inactive' Quote Link to comment Share on other sites More sharing options...
phs2911 Posted January 14, 2010 Author Share Posted January 14, 2010 Thanks mjdamato!! What a simple fix to a problem that perplexed me for so long last night. Thanks! I'm really glad I found this site. It's extremely helpful... Quote Link to comment 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.