Create a category management page
After completing the basic addition, deletion, modification and query functions of the main page content, we need to complete the implementation of the addition, deletion, modification and query functions of category management.
In this section we will first complete the creation of the main page of category management. Change cate.html in the admin folder to cate.php.
The idea of adding, deleting, modifying, and querying in category management is basically the same as the implementation of the adding, deleting, modifying, and querying function of the index main page content. SQL statements are used to query all the information in the database and display it on the page.
I want to achieve the following effect here:
Need to learn the implementation of Infinitus classification:
<?php function getList($pid=0,&$result=array(),$spac=0) { global $link; $spac +=8; $sql = "select * from cate where pid = $pid"; $res = mysqli_query($link,$sql); while($rows=mysqli_fetch_array($res)) { $rows["cate_name"] = str_repeat(' ',$spac).'--'.$rows["cate_name"]; $result[] = $rows; getList($rows['id'],$result,$spac); } return $result; } $rs=getList(); ?>
Of course it still needs to be modified Download html and css styles.
Call this custom function of Infinitus classification and perform forerch on the cate.php page to loop out the data
<?php foreach($rs as $key => $val){?> <tr> <td><?php echo $val["id"]?></td> <td style="text-align: left; padding-left: 15%"><?php echo $val["cate_name"]?></td> <td><?php echo $val["rank"]?></td> <td> <div class="button-group"> <a class="button border-main" href="cateedit.php?id=<?php echo $val['id'];?>"> <span class="icon-edit"></span> 修改</a> <a class="button border-red" href="catedel.php?id=<?php echo $val['id'];?>" onclick="return del(1,2)"> <span class="icon-trash-o"></span> 删除</a> </div> </td> </tr> <?php }?>