PHP mySQL using xamp Move data table to other table

<?php
$connect = mysqli_connect("localhost", "root", "", "root");
if(isset($_POST["id"]))
{
 foreach($_POST["id"] as $id)
 {
  $query = "INSERT INTO tbl_released (id, branch, outlet, user, item, serialno, dater, problem, status, remarks, tech)
  SELECT id, branch, outlet, user, item, serialno, dater, problem, status, remarks, tech
  FROM tbl_repair WHERE id = '".$id."'";
  mysqli_query($connect, $query);
 
 }
}
?>

that code copy data from tbl_repair to tbl_released. now What I want to happen is to copy data and remove it from source table which is tbl_repair. Something that I want to move the data.
i tried the code
<?php
$connect = mysqli_connect("localhost", "root", "", "root");
if(isset($_POST["id"]))
{
 foreach($_POST["id"] as $id)
 {
  $query = "INSERT INTO tbl_released (id, branch, outlet, user, item, serialno, dater, problem, status, remarks, tech)
  SELECT id, branch, outlet, user, item, serialno, dater, problem, status, remarks, tech
  FROM tbl_repair WHERE id = '".$id."' DELETE FROM tbl_repair";
  mysqli_query($connect, $query);
 
 }
}
?>
but the code is not working...can you help me guys how to solve my problem...
repmove.php
Yaku KakashiAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

kenfcampCommented:
First check your code for typo's and see if that resolves your issue

You've indicated two tables tbl-released and tbl-repair and your code references 3:  
tbl_released, tbl_repair, and tbl-repair

$query = "INSERT INTO tbl_released (id, branch, outlet, user, item, serialno, dater, problem, status, remarks, tech)
  SELECT id, branch, outlet, user, item, serialno, dater, problem, status, remarks, tech
  FROM tbl_repair WHERE id = '".$id."' DELETE FROM tbl-repair";

Ken
1
Yaku KakashiAuthor Commented:
Thanks Bro. Corrected. Can you help me to solve the issue?... Thanks in advance
0
kenfcampCommented:
Well assuming that your copy code works,

{

$query = "INSERT INTO tbl_released (id, branch, outlet, user, item, serialno, dater, problem, status, remarks, tech)
SELECT id, branch, outlet, user, item, serialno, dater, problem, status, remarks, tech FROM tbl_repair WHERE id = '".$id."'";
mysqli_query($connect, $query);

$delquery = "delete from tbl_repair where id = '$id'";
mysqli_query($connect, $delquery);

}
1

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Yaku KakashiAuthor Commented:
It works like a charm...Thank you so much...
0
kenfcampCommented:
You are welcome
1
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.