希望通过将记录从一个表移动到另一个表来存档患者。这是我尝试使用的代码:
<?php
$patient_id = $_GET['patient_id'];
include("db.php");
$sql="Select * from patient where patient_id=".$patient_id;
$result=mysqli_query($conn,$sql);
$row=mysqli_fetch_array($result);
//Call the function to archive the table
//Function definition is given below
archive_record(patient,$row);
//Once you archive, delete the record from original table
$sql = "Delete from patient where patient_id=".$patient_id;
mysqli_query($conn,$sql);
function archive_record($patient_archive,$row)
{
$sql = "insert into patient_archive values(";
$i=0;
while($i<(count($row)-1))
{
$sql.="'".$row[$i]."',";
}
$i=$i+1;
$sql.="'".$row[$i]."'";
$sql.=")";
}
?>
我在运行代码enter image description here后得到这个结果
如何改进此代码以获得所需的结果?
调试后出错请在此处输入图像描述
1条答案
按热度按时间f3temu5u1#
可以使用此函数复制行: