PHPが簡易ニュースリリースシステムとニュース一覧ページ削除機能モジュールを開発

このセクションのはじめに このセクションでは、ニュース一覧ページからニュースを削除する方法と、データベース内のニュースの記録を削除する方法を紹介します。

やはりデータベースを操作せずに行うことはできません。ここでは、delete を使用する必要があります: データ テーブル内のデータを削除します

アイデア:

データ パスの新しいテーブルの ID フィールドを削除してニュースを削除します。 table

1608.png

SQL ステートメントは次のとおりです:

<?php
$sql = "delete from new where id = '$id'";
?>

削除関数を実装する完全な delete.php ファイル:

<?php
 header("content-type:text/html;charset=utf8");
 $link = mysqli_connect('localhost','root','root','test');
       mysqli_set_charset($link, "utf8");
       
 if (!$link) {
   die("连接失败:".mysqli_connect_error());
 }
 $id = $_GET['id'];
 $sql = "delete from new 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>";
 }
?>


学び続ける
||
<?php header("content-type:text/html;charset=utf8"); $link = mysqli_connect('localhost','root','root','test'); mysqli_set_charset($link, "utf8"); if (!$link) { die("连接失败:".mysqli_connect_error()); } $id = $_GET['id']; $sql = "delete from new 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>"; } ?>
私たちについて 免責事項 Sitemap
PHP中国語ウェブサイト:福祉オンライン PHP トレーニング,PHP 学習者の迅速な成長を支援します!