標籤:exp lod 資料庫 選項 項目 篩選 條件 min web
<tr>
<td width="100">品牌</td>
<td>
<?php echo SqlSelect(‘goods where 1=1‘,‘brand‘,‘select‘,‘brand‘,‘-請選擇品牌-‘); ?>
</td>
</tr>
/**********資料庫篩選菜單********************************************************/
/**
* value 為ID時顯示函數
* @param string $SqlForm 表名+條件 admin where id = ‘$id‘
* @param string $SqlId 前端要顯示的value 一般為資料庫欄位
* @param string $SqlColumn 前端頁面顯示的title
* @param string $title 預設顯示,--請選擇--
* @param string $value 預設值的ID
*/
function SqlSelect($SqlForm,$SelectName,$class,$SqlColumn,$title){
$SearchSql = mysql_query("select * from {$SqlForm}");
while($Search = mysql_fetch_array($SearchSql)){
$key = $Search[$SqlColumn];
$option[$key] = $key;
}
return select($SelectName,$class,$title,$option);
}
/**********option列印函數********************************************************/
/**
* 列印函數
* @param string $title 預設第一個option
* @param array $option 選項集合 array(‘男‘,‘女‘)
* @param string $value 預設使用者選中
* @return 返回結果
*/
function option($title,$option,$value){}
<tr>
<td width="100">語種</td>
<td>
<select name="oLanguage" class="select textPrice">
<?php echo option(‘-請選擇語種-‘,explode(‘,‘,website(‘language‘)),$value);?>
</select>
</td>
</tr>
/**********輸出網站自訂文字********************************************************/
function website($id){
$website = query("website"," webid = ‘$id‘ ");
return $website[‘text‘];
}
/**********拆分字串為數值**************/
explode(‘邊界符‘,‘拆分的字串‘);
/*************拆分段落************/
."".
/***************讀取日期返回前端頁面******************/
<td width="100">交貨日期</td>
<td>
<?php
$dArr = explode("-",$res[‘deliveryDate‘]);
echo year(‘year‘,‘select‘,‘‘,$dArr[0]).moon(‘moon‘,‘select‘,$dArr[1]).day(‘day‘,‘select‘,$dArr[2]) ;?>
</td>
/*****************網域名稱傳值接收方式*******************/
$id = $get[‘id‘];
/**************查詢單條資料執行方式*****************/
$res = query("buycar","id=‘$id‘");
/**
* vlaue為ID號的菜單
* @param string $SqlForm 表名+
* @param string $SelectName select 控制項名字select name=""
* @param string $class 控制項的類
* @param string $SqlId value ID <option value> </option>
* @param string $SqlColumn 前端頁面顯示的title <option value> title</option>
* @param string $title 預設顯示,--請選擇--
* @param string $value 有值的時候,預設選中該值
*/
function IDSelect($SqlForm,$SelectName,$class,$SqlId,$SqlColumn,$title,$value){
$SearchSql = mysql_query("select * from {$SqlForm}");
while($Search = mysql_fetch_array($SearchSql)){
$key = $Search[$SqlId];
$option[$key] = $Search[$SqlColumn];
}
return select($SelectName,$class,$title,$option,$value);
}
function select($name,$class,$title,$option,$value){
$result = "
<select name=‘{$name}‘ class=‘{$class}‘>
".option($title,$option,$value)."
</select>
";
//返回一個完整的下拉式功能表
return $result;
}
<!-- //管理控制項 -->
<tr>
<td width="100">品牌</td>
<td>
<?php echo IDSelect(‘goods where 1=1‘,‘brand‘,‘select‘,‘brand‘,"brand",‘-請選擇品牌-‘,$goods[‘brand‘]); ?>
</td>
</tr>
今天是專案經理指導學習PHP實戰項目的第二天下