I used this code
<?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);
?>
and this copies the content from one table to another, how do I move ( delete from current table and move to another table ) ??
1) Copy the record
$sql1="INSERT INTO nominated select * from student where regno = ".intval($_POST["regno"]);
2) Delete the original one
$sql2="DELETE from student where regno = ".intval($_POST["regno"]);
Execute both queries. Remember to sanitize your POST variable before doing so.
Edit:
You asked how to execute both of them, here is how you can do that using your own code
$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
}
}
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments