我用了这个代码
<?php
$con=mysqli_connect("localhost","willy","12345","mop");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$sql="INSERT INTO nominated select * from student where regno = '$_POST[regno]'";
if (!mysqli_query($con,$sql))
{
die('Error: ' . mysqli_error($con));
}
header("location:form5_1.php");
mysqli_close($con);
?>这会将内容从一个表复制到另一个表,如何移动(从当前表中删除并移动到另一个表)?
发布于 2014-01-17 15:26:22
1)复制记录
$sql1="INSERT INTO nominated select * from student where regno = ".intval($_POST["regno"]);2)删除原来的
$sql2="DELETE from student where regno = ".intval($_POST["regno"]);执行这两个查询。在这样做之前,记得净化你的POST变量。
编辑:
您询问了如何执行这两种方法,下面是如何使用您自己的代码来实现的。
$sql1="INSERT INTO nominated select * from student where regno = ".intval($_POST["regno"]);
if (!mysqli_query($con,$sql1))
{
// your error checking here
}
else
{
$sql2="DELETE from student where regno = ".intval($_POST["regno"]);
if (!mysqli_query($con,$sql2)
{
// your error checking here
}
}发布于 2014-01-17 15:26:47
MOVE SQL语句不存在。您必须将愿望记录插入新表并从旧表中删除它。
https://stackoverflow.com/questions/21189466
复制相似问题