这是将一些数据从一个表移动到另一个表的答案,它可能不是最好的,但它确实有效。
$result = mysqli_query($con,"SELECT * FROM Teacher_staff");
while($row = mysqli_fetch_array($result))
{
// you don't need this step but it checks the select data portion
echo $row['First'] . " " . $row['Last'] . " " . $row['Id'];
// assign your variables, might not need this step as well
$First = $row['First'];
$Last = $row['Last'];
$id = $row['Id'];
// takes the information from the first mysqli and inserts it into the second table.
$sql="INSERT INTO teachers (First, Last, Id)
VALUES
(
'".addslashes($First)."',
'".addslashes($Last)."',
'".addslashes($Depart)."',
'".addslashes($id)."'
)";
if (!mysqli_query($con,$sql))
{
die('Error: ' . mysqli_error($con));
}
// confirms that each record is added to the table.
echo "1 record added";
}
echo "<br>";
mysqli_close($con);
echo "done";
无论如何感谢您的帮助....哦,我修复了它,以便“'”不会出错。