tags:

views:

29

answers:

1

In one of the sites I manage, the client has decided to take on ACH/Bank Account administration where it was previously outsourced. As a result, the information submitted in our online form which used to simply store in a single database for processing now must sit in 'limbo' until the funds used for payment have been verified. My original plan is as follows:

At the end of an enrollment, all form data is collected and stored in a single MySQL database. Our internal administrator will receive an email notification reminding him enrollments have taken place. He will process the ACH information collected and wait the 3-4 business days needed for payment to clear.

Once the payment information has been returned as Good (haven't considered what I will do with the 'bad' yet), the administrator can log into a secure portal which allows him to click a button to 'process' the full information once compared and verified. the process is simplified as:

  1. Enrollment complete: data stored in DB 'A'
  2. Funds verified and link clicked: data from 'A' is copied to DB 'B' and 'A' is deleted.

I have run similar processes with CSV output before and simply used

//transfers old data to archive
$transfer = mysql_query('INSERT INTO '.$archive.' SELECT * FROM '.$table) or die(mysql_error());

//empties existing table
$query = mysql_query('TRUNCATE TABLE '.$table) or die(mysql_error());

but in those cases, ALL data returned was copied and deleted. I only want to copy and delete a single record.

Any idea how to accomplish this?

+1  A: 

but in those cases, ALL data returned was copied and deleted. I only want to copy and delete a single record.

Any idea how to accomplish this?

Add a WHERE clause to the SELECT * FROM?

INSERT INTO tablename SELECT * FROM tablename2 WHERE record_id_field = 'value';
Pekka
@Pekka - thanks for the help. Given that I am returning the data in rows and will only process row by row, I won't know the given name or value of the row being copied.
JM4
@JM4 why not? Why can't you get the current row's ID?
Pekka
@Pekka - i suppose I could then. Just based on the sample code you mention above I wasn't sure how it fit in. I have shown how I display the information above to the administrator.
JM4
@pekka - i should really look at my own code. I use almost the 'exact' same code for deleting a bad record. My apologies and thank you for the help!
JM4