Pengubahsuaian dan pemadaman lajur

Dalam bab sebelumnya, kami telah menambah fungsi lajur dan senarai paparan lajur Pada halaman paparan, kami mempunyai kod berikut:

<td>
    <a class="link-update" href="cate_edit.php?id=<?php echo $v['id'];?>">修改</a>
    <a class="link-del" onclick="return confirm('确定删除当前数据?')" href="cate_del.php?id=<?php echo $v['id']; ?>">删除</a>
</td>

Di sini kami telah memperoleh id lajur yang sepadan, yang perlu dipaparkan pada. halaman yang sepadan Selepas menerima ID ini, anda boleh melengkapkan pengubahsuaian dan pemadaman lajur melalui operasi pada pangkalan data.

Pertama sekali, kami akan melakukan fungsi pengubahsuaian dengan mengklik halaman pengubahsuaian akan memasuki halaman berikut:

0.jpg

Di sini kami akan mengeluarkan fail yang telah ditambahkan ke pangkalan data, dan kemudian memaparkan data pada bahagian. halaman. Kod adalah seperti berikut:

<?php
include_once('../../common/config.php');
$id=$_GET['id'];
$sql="select * from cate WHERE id='$id'";
$que=mysqli_query($conn,$sql);
$row=mysqli_fetch_assoc($que);

function getList($pid=0,&$result=array(),$spac=0)
{
    global $conn;
    $spac +=4;
    $sql = "select * from cate where pid = $pid";
    $res = mysqli_query($conn,$sql);
    while($rows=mysqli_fetch_array($res))
    {
        $rows["name"] = str_repeat('&nbsp;',$spac).'|--'.$rows["name"];
        $result[] = $rows;
        getList($rows['id'],$result,$spac);
    }
    return $result;
}
$rs=getList();
//print_r($rs);
//die;
?>

<!doctype html>
<html>
<head>
    <meta charset="UTF-8">
    <title>栏目修改--后台管理</title>
    <link rel="stylesheet" type="text/css" href="../../public/style/css/common.css"/>
    <link rel="stylesheet" type="text/css" href="../../public/style/css/main.css"/>
    <script type="text/javascript" src="../../public/style/js/libs/modernizr.min.js"></script>
    <script type="text/javascript" charset="utf-8" src="../../public/ueditor/ueditor.config.js"></script>
    <script type="text/javascript" charset="utf-8" src="../../public/ueditor/ueditor.all.min.js"></script>
    <script type="text/javascript" charset="utf-8" src="../../public/ueditor/lang/zh-cn/zh-cn.js"></script>
</head>
<body>
<?php include_once("../../common/top.php"); ?>

<div class="container clearfix">

    <?php include("../../common/left.php"); ?>
    <!--/sidebar-->
    <div class="main-wrap">

        <div class="crumb-wrap">
            <div class="crumb-list"><i class="icon-font"></i><a href="../index.php">首页</a><span class="crumb-step">></span><a class="crumb-name" href="cate_list.php">栏目管理</a><span class="crumb-step">></span><span>新增作品</span></div>
        </div>
        <div class="result-wrap">
            <div class="result-content">
                <form action="cate_upd.php" method="post" id="myform" name="myform" enctype="multipart/form-data">
                    <input type="hidden" name="id" value="<?php echo $id;?>">
                    <table class="insert-tab" width="100%">
                        <tbody>

                        <tr>
                            <th><i class="require-red">*</i>栏目标题:</th>
                            <td>
                                <input class="common-text required" id="title" name="name" size="50" value="<?php echo $row['name'];?>" type="text">
                            </td>
                        </tr>
                        <tr>
                            <th><i class="require-red">*</i>栏目类型:</th>
                            <td>
                                <select name="modelid" class="form-control">

                                   <option <?php if($row['modelid']==1){
                                       echo "selected";
                                   } ?> value='1'>文章模型</option>;

                                   <option <?php if($row['modelid']==2){
                                       echo "selected";
                                   } ?> value='2'>单页模型</option>;

                                   <option <?php if($row['modelid']==3){
                                       echo "selected";
                                   } ?> value='3'>产品模型</option>;

                                   <option <?php if($row['modelid']==4){
                                       echo "selected";
                                   } ?> value='4'>图片模型</option>;

                                    ?>
                                </select>
                            </td>
                        </tr>
                        <tr>
                            <th><i class="require-red">*</i>栏目状态:</th>
                            <td>
                                <input type='radio' <?php if($row['status']==1){
                                   echo "checked";
                                } ?> name='status' value='1'/>显示&nbsp&nbsp
                                <input type='radio' <?php if($row['status']==0){
                                    echo "checked";
                                } ?>  name='status' value='0'/>隐藏
                            </td>
                        <tr>
                            <th>关键词:</th>
                            <td>
                                <input class="common-text required" id="title" name="keywords" size="50" value="<?php echo $row['keywords'];?>" type="text">
                            </td>
                        </tr>
                        <tr>
                            <th>内容:</th>
                            <td><textarea name="content" class="common-textarea" id="content" cols="30" style="width: 98%;" rows="10"><?php echo $row['content'] ?></textarea></td>
                        </tr>
                        <tr>
                            <th></th>
                            <td>
                                <input class="btn btn-primary btn6 mr10" value="提交" type="submit">
                                <input class="btn btn6" onclick="history.go(-1)" value="返回" type="button">
                            </td>
                        </tr>
                        </tbody></table>
                </form>
            </div>
        </div>

    </div>
    <!--/main-->
</div>
</body>
</html>
<script type="text/javascript">

    UE.getEditor('content',{initialFrameWidth:1100,initialFrameHeight:400,});

</script>

Data dikeluarkan, dan kemudian data dihantar ke halaman yang sepadan Selepas menerimanya, gunakan pernyataan sql untuk menyimpannya ke pangkalan data data pada halaman ini. Hanya tukar atribut tindakan borang borang Hanya tetapkan ia kepada kosong Berikut adalah kod untuk halaman yang menerima pengubahsuaian data .

Apa yang anda perlu beri perhatian semasa memadam ialah kerana lajur kami mempunyai klasifikasi peringkat kedua, apabila anda ingin memadam kategori peringkat atas, anda mesti memadamkan subkategori di bawah kategori peringkat atas dahulu, jika tidak pemadaman tidak dibenarkan. Diamante adalah seperti berikut:
Meneruskan pembelajaran
||
<?php include_once('../../common/config.php'); $id=$_GET['id']; $sql="select * from cate WHERE id='$id'"; $que=mysqli_query($conn,$sql); $row=mysqli_fetch_assoc($que); function getList($pid=0,&$result=array(),$spac=0) { global $conn; $spac +=4; $sql = "select * from cate where pid = $pid"; $res = mysqli_query($conn,$sql); while($rows=mysqli_fetch_array($res)) { $rows["name"] = str_repeat(' ',$spac).'|--'.$rows["name"]; $result[] = $rows; getList($rows['id'],$result,$spac); } return $result; } $rs=getList(); //print_r($rs); //die; ?> <!doctype html> <html> <head> <meta charset="UTF-8"> <title>栏目修改--后台管理</title> <link rel="stylesheet" type="text/css" href="../../public/style/css/common.css"/> <link rel="stylesheet" type="text/css" href="../../public/style/css/main.css"/> <script type="text/javascript" src="../../public/style/js/libs/modernizr.min.js"></script> <script type="text/javascript" charset="utf-8" src="../../public/ueditor/ueditor.config.js"></script> <script type="text/javascript" charset="utf-8" src="../../public/ueditor/ueditor.all.min.js"></script> <script type="text/javascript" charset="utf-8" src="../../public/ueditor/lang/zh-cn/zh-cn.js"></script> </head> <body> <?php include_once("../../common/top.php"); ?> <div class="container clearfix"> <?php include("../../common/left.php"); ?> <!--/sidebar--> <div class="main-wrap"> <div class="crumb-wrap"> <div class="crumb-list"><i class="icon-font"></i><a href="../index.php">首页</a><span class="crumb-step">></span><a class="crumb-name" href="cate_list.php">栏目管理</a><span class="crumb-step">></span><span>新增作品</span></div> </div> <div class="result-wrap"> <div class="result-content"> <form action="cate_upd.php" method="post" id="myform" name="myform" enctype="multipart/form-data"> <input type="hidden" name="id" value="<?php echo $id;?>"> <table class="insert-tab" width="100%"> <tbody> <!-- <!--<tr>--> <!-- <th width="120"><i class="require-red">*</i>分类:</th>--> <!-- <td>--> <!----> <!-- <select name="pid" id="catid" class="required">--> <!-- <option value="0">    |--顶级栏目</option>--> <!-- --><?php ///* foreach($rs as $k=>$v){ // */?> <!-- <option --><?php ///*if($v['id']==$id) { // echo "selected"; // }*/?><!-- value='--><?php ///*echo $v['id']*/?><!--'>--><?php ///*echo $v['name']; */?><!--</option>--> <!-- --><?php ///* } // */?> <!-- </select>--> <!----> <!-- </td>--> <!-- </tr>--> <tr> <th><i class="require-red">*</i>栏目标题:</th> <td> <input class="common-text required" id="title" name="name" size="50" value="<?php echo $row['name'];?>" type="text"> </td> </tr> <tr> <th><i class="require-red">*</i>栏目类型:</th> <td> <select name="modelid" class="form-control"> <option <?php if($row['modelid']==1){ echo "selected"; } ?> value='1'>文章模型</option>; <option <?php if($row['modelid']==2){ echo "selected"; } ?> value='2'>单页模型</option>; <option <?php if($row['modelid']==3){ echo "selected"; } ?> value='3'>产品模型</option>; <option <?php if($row['modelid']==4){ echo "selected"; } ?> value='4'>图片模型</option>; ?> </select> </td> </tr> <tr> <th><i class="require-red">*</i>栏目状态:</th> <td> <input type='radio' <?php if($row['status']==1){ echo "checked"; } ?> name='status' value='1'/>显示&nbsp&nbsp <input type='radio' <?php if($row['status']==0){ echo "checked"; } ?> name='status' value='0'/>隐藏 </td> <tr> <th>关键词:</th> <td> <input class="common-text required" id="title" name="keywords" size="50" value="<?php echo $row['keywords'];?>" type="text"> </td> </tr> <tr> <th>内容:</th> <td><textarea name="content" class="common-textarea" id="content" cols="30" style="width: 98%;" rows="10"><?php echo $row['content'] ?></textarea></td> </tr> <tr> <th></th> <td> <input class="btn btn-primary btn6 mr10" value="提交" type="submit"> <input class="btn btn6" onclick="history.go(-1)" value="返回" type="button"> </td> </tr> </tbody></table> </form> </div> </div> </div> <!--/main--> </div> </body> </html> <script type="text/javascript"> UE.getEditor('content',{initialFrameWidth:1100,initialFrameHeight:400,}); </script>
  • Cadangan kursus
  • Muat turun perisian kursus
Tentang kita Penafian Sitemap
Laman web PHP Cina:Latihan PHP dalam talian kebajikan awam,Bantu pelajar PHP berkembang dengan cepat!