$row['kind'] = isset($row['kind']) ? $row['kind']: "";
$row['kind_options'] = get_kind_options($row['kind']);
```
程式 - 函數(取得選項,傳入預設值,selected 代表選擇) ```
function get_kind_options($default=""){
global $db;
$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 .="";
}
return $options;
}
```
樣板 ```
```
2. 商品價格
樣板 ```
```
3. 商品數量
樣板 ```
```
4. 結果
![](https://www.ugm.com.tw/uploads/tad_book3/image/10602/10/step_10_2.jpg)