What DB are you using?
If MS-SQL then I would create a Stord Procedure and the run it.
If MySQL then you may want to do it in two parts.
One page copies all records to the new table, executing a
'insert into tablename
select from tablename'
after doing this redirects to a second page that gets all variables from the previous one, identifies records to be removed and executes a 'delete table name where...' statement.
If you post more info then I can be more specific.
Bye
Qatqat
Life is what happens when you are making other plans.