The following code is exectued when i click on a button where the record in a database table(named order) is deleted and inserted into another database table(named complete) with same attributes!
<?php
include("includes/db.php"); // contains database connection
if( isset($_GET['del']) )
{
$id = $_GET['del'];
$sql1="INSERT INTO complete
(`OrderNo.`,`NIC`,`DP`,`Address`,`DPTime`,`Telephone`,`Email`,
`Image1`,`ImageName1`,
`Image2`,`ImageName2`,
`Image3`,`ImageName3`)
SELECT
`OrderNo.`,`NIC`,`DP`,`Address`,`DPTime`,`Telephone`,`Email`,
`Image1`,`ImageName1`,
`Image2`,`ImageName2`,
`Image3`,`ImageName3`
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));
echo "<meta http-equiv='refresh' content='0;url=vieworders.php'>";
}
?>
since the 'where' clause has 'Orderno.' attribute the efficiency of the database can be improved using an index for the orderNo. attribute! How can i achieve this? where do i need to put the query " CREATE INDEX orderindex on `order(OrderNo.) "?
You can just run an MySQL client (console mysql, phpMyAdmin, heidisql, workbanch) and execute it.