亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

How to implement the delete function

In the main page of the background, we find the Modify/Delete button pattern under the operation column as shown below. In this chapter, we will first talk about how to implement the function of deleting a piece of data.

32.png

The main idea of ??realizing the deletion function is to obtain the id of the data that needs to be deleted, and delete this through SQL statements Book id to delete all records of this id in the database table.

First create a delete.php file

Get it in list.php The path of id is then deleted. Make the following modifications in list.php, $rows["id"] is output through the while loop in the previous section.

<td>
    <div class="button-group">
        <a class="button border-main" href="#"><span class="icon-edit"></span>修 改</a>
        <a class="button border-red" href="delete.php?id=<?php echo $rows["id"]?>" onclick="return del(1,1,1)">
            <span class="icon-trash-o"></span>刪 除
        </a>
    </div>
</td>

delete.php file, import the database public file config.php, get the value of the id and delete this data in the database. Write the following code:

<?php
header("content-type:text/html;charset=utf-8");
include("config.php");

$id = isset($_GET['id'])?$_GET['id']:"";
$sql = "delete from list where id = '$id'";
//echo $sql;
$rel = mysqli_query($link,$sql);
if($rel){
   echo "<script>alert('刪除成功');window.location.href='list.php'</script>";
}else{
   echo "<script>alert('刪除失敗');window.location.href='list.php'</script>";
}
?>



Continuing Learning
||
<?php header("content-type:text/html;charset=utf-8"); include("config.php"); $id = isset($_GET['id'])?$_GET['id']:""; $sql = "delete from list where id = '$id'"; //echo $sql; $rel = mysqli_query($link,$sql); if($rel){ echo "<script>alert('刪除成功');window.location.href='list.php'</script>"; }else{ //echo "<script>alert('刪除失敗');window.location.href='list.php'</script>"; } ?>
submitReset Code