Copy selected field to another table

i can delete selected field with this code.

i want to copy selected field to another table, which fields do i need to edit.
(copy selected field from orders to orders2 table)

Thank you

$arr=[i];
[total_chked][$arr]={part_no};
[i]++;

//To delete the record uncomment the line below:
sc_exec_sql(“delete from orders where orderid = ‘{orderid}’”);

This codes working but if i click 2 times to button, records 2 times with same record.
i don’t want to record if record already exist.

$arr=[i];
[total_chked][$arr]={part_no};
[i]++;

if(count([total_chked]) > 0)
{

$sql = “INSERT INTO orders2 (order2id, orderno, part_no, description, qty, each_net, total_net, delivery, note, comission, price_each, price_total) SELECT orderid, orderno, part_no, description, qty, each_net, total_net, delivery, note, comission, price_each, price_total FROM orders where orderid =’{orderid}’”;
sc_exec_sql($sql);
[selected] = array();
}