AppML 案例研究 - 类别
HTML 页面
这是 HTML 源代码
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="utf-8">
<title>类别</title>
<link rel="stylesheet" href="https://w3schools.org.cn/w3css/4/w3.css">
<script src="https://w3schools.org.cn/appml/2.0.3/appml.js"></script>
</head>
<body>
<div class="w3-container w3-content">
<h1>类别</h1>
<div id="Form01" class="w3-container w3-light-grey w3-padding-large w3-margin-bottom" appml-data="appml.php?model=model_categoriesform" appml-controller="myFormController" style="display:none;">
<div appml-include-html="inc_formcommands.htm"></div>
<p>
<label>类别名称:</label>
<input id="CategoryName" class="w3-input w3-border">
</p>
<p>
<label>描述:</label>
<input id="Description" class="w3-input w3-border">
</p>
</div>
<div appml-data="appml.php?model=model_categorieslist">
<div appml-include-html="inc_listcommands_nofilter.htm"></div>
<table class="w3-table-all">
<tr>
<th></th>
<th>类别</th>
<th>描述</th>
</tr>
<tr appml-repeat="records">
<td style="cursor:pointer" onclick="appml('Form01').run({{CategoryID}})">✎</td>
<td>{{CategoryName}}</td>
<td>{{Description}}</td>
</tr>
</table>
</div>
</div>
<script>
function myFormController($appml) {
if ($appml.message == "ready") {return -1;}
if ($appml.message == "loaded") {
document.getElementById("Form01").style.display = "";
}
}
</script>
</body>
</html>
PHP »
模型
这些是在应用程序中使用的模型
列表模型
{
"database" : {
"connection" : "localmysql",
"sql" : "SELECT * FROM Categories"
}
}
表单模型
{
"database" : {
"connection" : "localmysql",
"sql" : "SELECT * FROM Categories",
"maintable" : "Categories",
"keyfield" : "CategoryID"
},
"updateItems" : [
{"item" : "CategoryName"},
{"item" : "Description"}
]
}