The following PHP script is used to retrieve a set of data (order numbers) in my database
<?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>";
?>
When the delete link in each ow is clicked that specific row must be deleted! The PHP script for deletion is as follows
< ?php
include("includes/db.php");
if( isset($_GET['del']) )
{
$id = $_GET['del'];
$sql= "DELETE FROM order WHERE OrderNo.='$id'";
$res= mysqli_query($db,$sql) or die("Failed".mysql_error());
}
?>
I did not redirect the 2nd PHP script to the initial one in order to identify the error! when the delete link is clicked i get the following on the screen with out any deletion of the row!
< ?php
include("includes/db.php");
if( isset($_GET['del']) ) {
$id = $_GET['del'];
$sql= "DELETE FROM order WHERE OrderNo.='$id'";
$res= mysqli_query($db,$sql) or die("Failed".mysql_error());
}
?>
How can I rectify this in order to delete a row when its delete link is clicked?