该法典行之有效。 我可以说明如何将数据插入db 如果用户首次使用“SAVE”纽吨或更新数据。
www.un.org/Depts/DGACM/index_spanish.htm php一侧
<?php
require ../../core/includes/common.php ;
$name=filter($_POST[ name ], $db);
$title=filter($_POST[ title ], $db);
$parentcheck=filter($_POST[ parentcheck ],$db);
if(isset ($_POST[ parent ])) $parent=filter($_POST[ parent ],$db);
else $parent=$parentcheck;
$menu=filter($_POST[ menu ], $db);
$content = $db->escape_string($_POST[ content ]);
$result=$db->query("INSERT INTO menu (parent, name, showinmenu) VALUES ( $parent , $name , $menu )") or die($db->error);
$new_id = $db->insert_id;
$result2=$db->query("INSERT INTO pages (id, title, content) VALUES ( $new_id , $title , $content )") or die($db->error);
if ($new_id>0){
echo "{";
echo "msg": "success" ;
echo "}";
}else{
echo "{";
echo
"err": "error" ;
echo "}";
}
?>
UPDATE
由于@jmlsteeke i 找到了途径
将这部法典放在html部分
<?php
$result=$db->query("INSERT INTO menu (parent, name, showinmenu) VALUES ( 555 , new , 0 )") or die($db->error);
$new_id = $db->insert_id;
$result2=$db->query("INSERT INTO pages (id, title, content) VALUES ( $new_id , new , new )") or die($db->error);
?>
添加以下文字:
<input type="hidden" name="id" value="<?=$new_id?>"/>
使用的服务器代码
$result=$db->query("UPDATE pages AS p, menu AS m SET m.parent= $parent , m.name= $name , m.showinmenu= $menu , p.id= $id , p.title= $title , p.content= $content WHERE m.id= $id AND p.id=m.id") or die($db->error);
感谢@jmlsteeke