我想通过单击“添加”按钮将特定行从数据库传递到另一个数据库。我的dbconnection包含在它的顶部。
这是我的代码
<table style="margin-left: 28%;">
<tr>
<th><h2>Product Code</h2></th>
<th><h2>Products and Services</h2></th>
<th><h2>Amount</h2></th>
<th><h2>Action</h2></th>
</tr>
<tr>
<?php
$select_query = "SELECT * FROM products_and_services";
$select_result = mysqli_query($connection,$select_query);
?>
<?php while ($rows = mysqli_fetch_row($select_result)):;
$id = $rows[0];
$prod_code = $rows[1];
$service = $rows[2];
$amount = $rows[3];
?>
<td style="text-align: center;"><?php echo $rows[1]; ?></td>
<td style="text-align: center;"><?php echo $rows[2]; ?></td>
<td style="text-align: center;"><?php echo $rows[3]; ?></td>
<td style="text-align: center;"><a href="" name="add">Add</td>
<?php
if(isset($_POST['add'])){
$sql = "INSERT INTO temp_table (Product_name,Product_price,Product_ID)
VALUES ('$service','$amount','$id')";
mysqli_query($db,$sql);
}
?>
</tr>
<?php endwhile ?>