一、種類
二、表單型態
enctype=
"multipart/form-data"
」
<form action="admin_prod.php" method="POST" role="form" id="opForm" enctype="multipart/form-data"> ....... </form>
<div class="col-sm-3"> <div class="form-group"> <label>圖片<span>(800x449)</span></label> <input type="file" name="pic" accept="image/*" class="form-control"> </div> </div>
<div class="col-sm-6"> <div class="form-group"> <label for="title">標題</label> <input type="text" class="form-control" id="title" name="title" value="<{$row.title}>"> </div> </div>
<div class="form-group"> <label for="summary">商品摘要</label> <textarea class="form-control" rows="4" id="summary" name="summary"><{$row.summary}></textarea> </div>
$DirName = "prod"; mk_dir(WEB_PATH . "/uploads/{$DirName}"); mk_dir(WEB_PATH . "/uploads/{$DirName}/image"); mk_dir(WEB_PATH . "/uploads/{$DirName}/flash"); include_once WEB_PATH . "/class/ck.php"; $fck = new CKEditor($DirName, "content", $row['content']); $fck->setHeight(350); $row['content'] = $fck->render();
<div class="form-group"> <label for="content">商品內容</label> <{$row.content}> </div>
$row['kind'] = isset($row['kind']) ? $row['kind']: ""; $row['kind_options'] = get_kind_options($row['kind']);程式 - 函數
function get_kind_options($default=""){ $kind_options = array( "1"=>"類別1", "2"=>"類別2", "3"=>"類別3", "4"=>"類別4", "5"=>"類別5" ); $options = ""; foreach($kind_options as $key=> $option){ $selected = ($default == $key) ? " selected":""; $options .="<option value='{$key}'{$selected}>{$option}</option>"; } return $options; }樣板
<div class="col-sm-3"> <div class="form-group"> <label for="kind">類別</label> <select name="kind" class="form-control" size="1"> <{$row.kind_options}> </select> </div> </div>
<div class="col-sm-3"> <div class="form-group"> <label style="display:block;">啟用</label> <input type="radio" name="enable" id="enable_1" value="1" <{if $row.enable == '1'}>checked<{/if}>> <label for="enable_1">啟用</label> <input type="radio" name="enable" id="enable_0" value="0" <{if $row.enable == '0'}>checked<{/if}>> <label for="enable_0">停用</label> </div> </div>
#目前日期时间戳記 1970 00:00:00 GMT 的秒數 $now = strtotime("now");//得到目前網頁伺服器的「时间戳記」 $row['date'] = isset($row['date']) ? $row['date']: $now; $row['date'] = date("Y-m-d",$row['date']);//格式化樣板 - 一般日期
<div class="col-sm-3"> <div class="form-group"> <label for="date">建立日期</label> <input type="text" class="form-control" id="date" name="date" value="<{$row.date}>"> </div> </div>
三、使用插件