alert(join("\\n", $ErrorMsgList)); $MyJS->goto("Back"); exit; } /* 插入数据库。 */ $SQL = "INSERT INTO {{$Page.TableName}} ({{$Page.FieldsString}}) VALUES({{$Page.InsertFields}})"; if(!$MyDB->query($SQL)) { die($MyDB->errorMsg()); } else { $MyTPL->assign("ItemID", $MyDB->insert_ID()); $MyTPL->display($_CFG["TPL"]); exit; } } {{if $Page.FieldsToPHP}} {{foreach from=$Page.FieldsToPHP key=FieldName item=InputParam}} {{if $InputParam.Table}} /* 查找{{$FieldName}}列表从{{$InputParam.Table}}中。*/ $SQL = "SELECT {{$InputParam.Fields.Value}} AS Value, {{$InputParam.Fields.Label}} AS Label FROM {{$InputParam.Table}}"; $ReaultID = $MyDB->query($SQL) or die($MyDB->errorMsg()); while($Item = $ReaultID->fetchRow()) { ${{$FieldName}}List[$Item['Value']] = $Item["Label"]; } $MyTPL->assign("{{$FieldName}}List", html{{$InputParam.Type}}(${{$FieldName}}List, "{{$FieldName}}")); {{elseif $InputParam.List}} /* 创建{{$FieldName}}列表。*/ {{foreach from=$InputParam.List key=ItemValue item=ItemLabel}} ${{$FieldName}}List["{{$ItemValue}}"] = "{{$ItemLabel}}"; {{/foreach}} $MyTPL->assign("{{$FieldName}}List", htmlSelect(${{$FieldName}}List, "{{$FieldName}}")); {{elseif $InputParam.FromGET}} /* 赋值{{$FieldName}},通过_GET方式获得。*/ $MyTPL->assign("{{$FieldName}}", $_GET["{{$FieldName}}"]); {{elseif $InputParam.Func}} /* 赋值{{$FieldName}},通过{{$InputParam.Func}}创建。*/ $MyTPL->assign("{{$FieldName}}List", htmlSelect({{$InputParam.Func}}(), "{{$FieldName}}")); {{/if}} {{/foreach}} {{/if}} /* 赋值,显示模板。 */ $MyTPL->assign("PageTitle", $_LANG["TableLabel"] . $_LANG["AddPage"]); $MyTPL->display($_CFG["TPL"]); ?>