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

PHPで開発したニュース管理システムの削除機(jī)能の実裝

表示ページについては、変更と削除の両方に ID を出力するステートメントがあります:

<a href="modifynew.php?id=<?php echo $row[' id'] ;?>">変更</a>

<a href="delnew.php?id=<?php echo $row['id'];?>">削除< / a>

ご覧のとおり、削除をクリックして delnew.php ページにジャンプします

注: 削除するには、ID を取得し、データベースにクエリを?qū)g行して削除ステートメントを記述する必要もあります。條件が必要です。そうしないと、どのデータを削除するかがわかりません。削除関數(shù)のフローチャート:

まずデータベースに接続しますdel.png

header("Content-type: text/html; charset=utf-8") ;//エンコーディングを設(shè)定します

$con =@ mysql_connect("localhost","root","root") または die("データベース接続に失敗しました");

mysql_select_db('news') または die("指定されたデータベースを使用できませんopens");

mysql_query("set names utf8 ");//データベースの文字セットを設(shè)定します

そして ID を取得します

$id = $_GET['id'];

最後に削除を書きますステートメント

$sql = "delete from new where id='$id '";

$res = mysql_query($sql);

if($res){

echo "<script>alert('削除成功') ;location.href='newlist.php';</script> ";}} Else {
echo" & lt; スクリプト & gt; local .href = 'newList.php'; & lt;/script & gt; ";


完全なコードは次のとおりです

<?php
    header("Content-type: text/html; charset=utf-8");//設(shè)置編碼
    $con =@mysql_connect("localhost","root","root") or die("數(shù)據(jù)庫連接失敗");
    mysql_select_db('news') or die("指定的數(shù)據(jù)庫不能打開");
    mysql_query("set names utf8");//設(shè)置數(shù)據(jù)庫的字符集

    $id = $_GET['id'];
    
    $sql = "delete from new where id='$id'";
    $res = mysql_query($sql);
    if($res){
        echo "<script>alert('刪除成功');location.href='newlist.php';</script>";
    }else{
        echo "<script>alert('刪除失敗');location.href='newlist.php';</script>";
    }
?>
學(xué)び続ける
||
<?php header("Content-type: text/html; charset=utf-8");//設(shè)置編碼 $con =@mysql_connect("localhost","root","root") or die("數(shù)據(jù)庫連接失敗"); mysql_select_db('news') or die("指定的數(shù)據(jù)庫不能打開"); mysql_query("set names utf8");//設(shè)置數(shù)據(jù)庫的字符集 $id = $_GET['id']; $sql = "delete from new where id='$id'"; $res = mysql_query($sql); if($res){ echo "<script>alert('刪除成功');location.href='newlist.php';</script>"; }else{ echo "<script>alert('刪除失敗');location.href='newlist.php';</script>"; } ?>
提出するリセットコード