Jump to content

Transcribe MySQL fields with PHP


phs2911

Recommended Posts

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!!!

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.