标签:
<?php include(‘medoo.min.php‘); $sqlData = new medoo(array( ‘database_type‘ => ‘mysql‘, ‘database_name‘ => ‘categorytree‘,//数据库名 ‘server‘ => ‘localhost‘,//数据库地址 ‘username‘ => ‘root‘,//数据库帐号 ‘password‘ => ‘root‘//数据库密码 )); header("Content-type: text/html; charset=utf-8"); if(isset($_POST[‘name‘]) && $_POST[‘name‘] !== "" && isset($_POST[‘pid‘]) && $_POST[‘name‘] !== ""): $name = $_POST[‘name‘]; $pid = $_POST[‘pid‘]; if($pid == 0): $sqlData->insert("category",array("name" => $name, "parentid" => $pid, "arrparentid" => 0, "child" => 0)); else: $UpArrPid = $sqlData->get("category", "arrparentid", array("id" => $pid)); $ArrParentid = $UpArrPid.",".$pid; $sqlData->insert("category",array("name" => $name, "parentid" => $pid, "arrparentid" => $ArrParentid, "child" => 0)); $sqlData->update("category", array("child" => 1),array("id[=]" => $pid)); endif; //若添加的是一级栏目的话那么parentid=0; echo "添加成功"; header("refresh:1;url=index.php"); else: echo "请填写栏目名称"; header("refresh:1;url=index.php"); endif; ?>
标签:
原文地址:http://www.cnblogs.com/sumiamsen/p/4261665.html