I want to insert all my fetch data into another table using PHP, but I can't figure out how to do it.
I already fetched the selected data as you can see in image using check box
and I can fetch it. I don't know if fetch is the right word
Here is the code that I use:
<?php
require '../config/connect.php';
require '../config/config.php';
if(isset($_POST['save_multicheckbox']))
{
foreach ($_POST['id'] as $id):
$query=mysqli_query($conn,"SELECT * FROM `liveselling` WHERE id='$id'");
//$srow=mysqli_num_rows($query);
$row=mysqli_num_rows($query);
if($row > 0)
{
while($result = mysqli_fetch_array($query)){
{
$customer = $result["customer"];
$code = $result["code"];
$supplier = $result["supplier"];
$product = $result["product"];
$qty = $result["qty"];
$price = $result["price"];
?>
<tr>
<td><?php echo $customer ?> </td>
<td><?php echo $code ?> </td>
<td><?php echo $supplier ?> </td>
<td><?php echo $product ?> </td>
<td><?php echo $qty ?> </td>
<td><?php echo $price ?> </td>
</tr>
<?php
}
}
}
endforeach;
}
else
{
echo'
<tr>
<td colspan = "4"><center>Record Not Found</center></td>
</tr>';
}
?>
Now how can I insert all the fetch data into new table in SQL?