码迷,mamicode.com
首页 > 其他好文 > 详细

代码测试

时间:2015-01-30 14:55:36      阅读:167      评论:0      收藏:0      [点我收藏+]

标签:

<?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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!