#顯示單筆
case "op_show":
op_show($sn);
break;
```
當新增、編輯記錄完成後,則顯示單筆記錄。
因此在新增的流程修改為:
```
#新增記錄
case "op_insert":
$sn=op_insert();
redirect_header("nav_m.php?op=op_show&sn={$sn}",3000,"新增資料成功!!");
break;
```
二、函數
```
########################################
# 顯示單筆
########################################
function op_show($sn="")
{
global $mysqli,$smarty;
if(!$sn)redirect_header("index.php",3000,"查詢選單資料錯誤!!");
#取得單筆記錄,可以寫成函數
$sql = "select *
from `show_kind`
where `sn`='{$sn}' and `kind`='nav_home'";
$result = $mysqli->query($sql) or die(printf("Error: %s
".$sql, $mysqli->sqlstate));
$DBV = $result->fetch_assoc();
#過濾撈出資料
$DBV['sn'] = intval($DBV['sn']);
//http://www.w3school.com.cn/php/func_string_htmlspecialchars.asp
$DBV['title'] = htmlspecialchars($DBV['title'], ENT_QUOTES); // 轉換雙引號和單引號
$DBV['url'] = htmlspecialchars($DBV['url'], ENT_QUOTES); // 轉換雙引號和單引號
$DBV['sort'] = intval($DBV['sort']);
$DBV['enable'] = $DBV['enable'] ? "是":"否";
$DBV['target'] = $DBV['target'] ? "是":"否";
$smarty->assign("DBV", $DBV);
return;
}
```
三、樣板
```
{* 選單管理 顯示單筆 *}
{if $WEB.file_name == "nav_m.php" and $op == "op_show"}
{/if}
```