类别展示功能 登录

类别展示功能

1,新建typelist.php文件

显示也做了无限极分类操作,代码如下所示:

<?php
header("Content-type:text/html;charset=utf-8");
    include 'include/mysqli.php';
?>
<!DOCTYPE html>
<html >
    <head>
        <meta charset="UTF-8">
        <title></title>
        <style>
            table td{padding: 5px 3px;}
            table tr{background: #33CCFF; height: 40px; line-height: 40px}
            /*table tr:nth-child(2n){background: #f0f0f0;}*/
        </style>
        <script>
            function delall(){
                var arrid="";
                obox=document.getElementsByName("box");
                for(i=0;i<obox.length;i++){
                    if(obox[i].checked){
                        arrid+=obox[i].value+",";
                    }
                }
                alert(arrid);
                window.location.href="typesave.php?action=delall&arrid="+arrid;
            }
        </script>
    </head>
    <body>
        <table width="100%">
            <tr><td><input type="checkbox">全选</td><td>编号</td><td>类别名称</td><td>排序</td></td><td>操作</td></tr>
            <?php
            function show($fid,$color,$i){
                $i++;
                $blank ="";
                for($n=0;$n<$i;$n++){
                    $blank.="---";
                }
                $rand=array('0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f');
                $color='#'.$rand[rand(0,15)].$rand[rand(0,15)].$rand[rand(0,15)].$rand[rand(0,15)].$rand[rand(0,15)].$rand[rand(0,15)];
                global $mysqli;
            $sql="select *from type where fid=$fid order by orderid asc";
            $result=$mysqli->query($sql);
            while($row=$result->fetch_assoc()){
            ?>
            <tr ><td><input type="checkbox" name="box" value="<?php echo $row['id']?>"></td><td><?php echo $row['id']?></td><td><?php echo $blank.$row['typename'].$blank?></td><td><?php echo $row['orderid']?></td><td><a href="typeupdate.php?fid=<?php echo $row['fid']?>&id=<?php echo $row['id']?>">修改</a>
                    <a href="typesave.php?action=del&id=<?php echo $row['id']?>">删除</a>
                    <a href="typeadd.php?id=<?php echo $row['id']?>">添加子类</a>
                </td></tr>
                
            <?php
//                $rand=array('0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f');
//                $color=$rand[rand(0,15)].$rand[rand(0,15)].$rand[rand(0,15)].$rand[rand(0,15)].$rand[rand(0,15)].$rand[rand(0,15)];
                show($fid=$row['id'],$color,$i);
            }
                 }
            show(0,$color='#33CCFF',0);
            ?>
            <table width="100%" >
                <tr style="background: #ffffff">
                    <td  width="10%"></td>
                    <td width="10%"></td>
                    <td width="50%"></td><td width="10%"></td>
                    <td><a href="javascript:delall()">全部删除</a><a href="typeadd.php"> 添加类别</a></td>
                </tr>
        </table>
    </body>
</html>

2,展示页面如下所示:

微信图片_20180306193923.png

下一节
<?php echo "分类页面显示功能";
提交 重置代码
章节 评论 笔记 课件
  • 取消 回复 发送
  • 取消 发布笔记 发送