当我点击一个数据库表(命名顺序)中的记录被删除并插入到具有相同属性的另一个数据库表(名为complete)的按钮时,以下代码被激活!
<?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'>";
}
?>
因为'where'子句有'Orderno'。使用orderNo的索引可以提高数据库的效率。属性!我怎样才能实现这一目标?我在哪里需要将查询“CREATE INDEX orderindex on order(OrderNo。)”?
答案 0 :(得分:0)
您可以运行MySQL客户端(控制台mysql,phpMyAdmin,heidisql,workbanch)并执行它。