php - Combine INSERT INTO SELECT, with DELETE at the same time -
i have button
<button onclick=save('save','."$id."']."')>save</button> once click it, want use ajax pass parameters php page perform following task mysql:
switch... case "save": $sql1 = "insert permanent_table (id, user, email) select id, user, email temp_table id='".$_get['id']."'"; $sql2 = "delete temp_table id='".$_get['id']."'"; whereby permanent_table having same structure temp_table. tried run both queries not working, guess not right way.
in case, question is:
- what real pro way use php/sql perform task?
- is there way can simplify/combine single query?
i think want
<button onclick="$.post('/php file name/', {'save','."$id."'}, function(data){});">save</button><br/> then run query's in php file.
$sql = $conn->prepare("insert `permanent_table` (`id`, `user`, `email`) values(?, ?, ?)"; $sql->bind_param("sss", $_get['id'], "", ""); $sql->execute(); $sql = $conn->prepare("delete `temp_table` `id`=?"); $sql->bind_param("s", $_get['id']); $sql->execute(); $sql = $conn->prepare("select `id`, `user`, `email` `temp_table` `id`=?"); $sql->bind_param("s", $_get['id']); $sql->execute(); //select last can grab results run them on way (pdo or mysql)
know lot query's feel free ask me!
Comments
Post a Comment