Pengenalan modul kepada bahagian belakang laman web - Pengurusan kategori (4) Ubah suai dan padamkan kategori

Bahagian ini akan memperkenalkan pautan yang sangat penting, pengurusan klasifikasi, yang merupakan teras penulisan laman web.

Apakah itu pengurusan kategori? Pengurusan klasifikasi merujuk kepada mengelaskan perkara ke dalam kategori, dan menggunakan kaedah pengurusan yang berbeza atau serupa kepada kategori yang berbeza.

Buat cateedit.php dan delete.php masing-masing di bawah admin, kodnya adalah seperti berikut:

cateedit.php:

rreee

delete.php :# 🎜🎜#

<?php 
    require_once("../config/config.php");
    mysql_query("set names = utf8");
      $sql = "SELECT * FROM cate"; 
      if($_GET){
        $cid = $_GET['cid'];
        $sql0 = 'select cate_name from cate where cid ='.$cid;
        $result =mysql_query($sql0);
        $cate_name = mysql_fetch_assoc($result)['cate_name'];
      }
      
      if($_POST){
        $id = $_POST['cid'];
        $cate_name=$_POST["cate_name"];
       
        $sql1 = 'select password from cate where cid='.$cid ;
        $result = mysql_query($sql1);
              $sql2 = 'UPDATE cate SET `cate_name`="'.$cate_name.'" where id ='.$cid;
              mysql_query ($sql2);
              header('location:./cate.php');
          }
      
 ?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta name="renderer" content="webkit">
<title></title>
<link rel="stylesheet" href="style/css/pintuer.css">
<link rel="stylesheet" href="style/css/admin.css">
<script src="style/js/jquery.js"></script>
<script src="style/js/pintuer.js"></script>
</head>
<body>
<div class="panel admin-panel margin-top">
  <div id="add"><strong><span></span>修改分类</strong></div>
  <div>
    <form method="post" action="cateedit.php" enctype="multipart/form-data">
      <div>
        <div>
          <label>分类名称:</label>
        </div>
        <input type="hidden" name="cid" value="<?php echo $cid;?>">
        <div>
          <input type="text" class="input w50" name="cate_name" value="<?php echo $cate_name;?>" />
          <div></div>
        </div>
      </div>        
      
      <div>
        <div>
          <label></label>
        </div>
        <div>
          <button class="button bg-main icon-check-square-o" type="submit"> 提交</button>
        </div>
      </div>
    </form>
  </div>
</div>
</body></html>

Pengubahsuaian dan pemadaman pengurusan kategori telah selesai, bukankah ia sangat mudah!

Meneruskan pembelajaran
||
<?php require_once("../config/config.php"); mysql_query("set names = utf8"); $sql = "SELECT * FROM cate"; if($_GET){ $cid = $_GET['cid']; $sql0 = 'select cate_name from cate where cid ='.$cid; $result =mysql_query($sql0); $cate_name = mysql_fetch_assoc($result)['cate_name']; } if($_POST){ $id = $_POST['cid']; $cate_name=$_POST["cate_name"]; $sql1 = 'select password from cate where cid='.$cid ; $result = mysql_query($sql1); $sql2 = 'UPDATE cate SET `cate_name`="'.$cate_name.'" where id ='.$cid; mysql_query ($sql2); header('location:./cate.php'); } ?> <!DOCTYPE html> <html lang="zh-cn"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" /> <meta name="renderer" content="webkit"> <title></title> <link rel="stylesheet" href="style/css/pintuer.css"> <link rel="stylesheet" href="style/css/admin.css"> <script src="style/js/jquery.js"></script> <script src="style/js/pintuer.js"></script> </head> <body> <div class="panel admin-panel margin-top"> <div class="panel-head" id="add"><strong><span class="icon-pencil-square-o"></span>修改分类</strong></div> <div class="body-content"> <form method="post" class="form-x" action="cateedit.php" enctype="multipart/form-data"> <div class="form-group"> <div class="label"> <label>分类名称:</label> </div> <input type="hidden" name="cid" value="<?php echo $cid;?>"> <div class="field"> <input type="text" class="input w50" name="cate_name" value="<?php echo $cate_name;?>" /> <div class="tips"></div> </div> </div> <div class="form-group"> <div class="label"> <label></label> </div> <div class="field"> <button class="button bg-main icon-check-square-o" type="submit"> 提交</button> </div> </div> </form> </div> </div> </body></html>
  • Cadangan kursus
  • Muat turun perisian kursus