The following php script is used to retrieve set of data(OrderNo.) from a database! when the delete link is clicked i want to remove the row in which that specific delete link exists and transfer the data to the 'transfer' table!
<?php
require("includes/db.php");
$sql="SELECT * FROM `order` ";
$result=mysqli_query($db,$sql);
echo"<head>";
echo'
<link rel="stylesheet" href="view.css">
<head>
';
echo"</head>";
echo "<body >";
echo "<table border=1 cellspacing=0 cellpadding=4 > " ;
echo"<tr bgcolor=grey>";
echo"<td align=center>";
echo "<font size=4>";
echo "<B>";
echo "Order No.";
echo "</B>";
echo"</td>";
echo"</tr>";
while($row=mysqli_fetch_array($result))
{
echo"<tr>";
echo"<td align=center>";
echo $row["OrderNo."];
echo "<br>";
echo"</td>";
echo "<td align=center>";
echo "<a href='delete.php?del=";
echo $row['OrderNo.'];
echo "'>delete</a>";
echo "<br>";
echo"</td>";
echo"</tr>";
}
echo"</table>";
?>
The following php script is executed when a delete link is clicked! when only the query for the delete function was executed it worked but after insertion of another query to transfer the values to 'transfer' table was written a syntax error occured.
<?php
include("includes/db.php");
if( isset($_GET['del']) )
{
$id = $_GET['del'];
$sql1="INSERT INTO transfer CompletedNo SELECT (OrderNo.) FROM `order` WHERE `OrderNo.` = '$id' ";
$res1= mysqli_query($db,$sql1) or die("Failed".mysqli_error($db));
$sql2= "DELETE FROM `order` WHERE `OrderNo.` = '$id' ";
$res2= mysqli_query($db,$sql2) or die("Failed".mysqli_error($db));
}
?>
please help me to correct it the error is only on line
$sql1="INSERT INTO transfer CompletedNo SELECT (OrderNo.) FROM `order` WHERE `OrderNo.` = '$id' ";
You need to use Parenthesis
around the Insert
column list
INSERT INTO transfer (CompletedNo)
SELECT `OrderNo.` FROM `order` WHERE `OrderNo.` = '$id'