destoon設(shè)置自定義搜索的方法
第一步:
在include/global.fun.php中加入兩個(gè)函數(shù)
函數(shù)一:
function loseSpace($pcon){
$pcon = preg_replace("/ /","",$pcon);
$pcon = preg_replace("/ /","",$pcon);
$pcon = preg_replace("/ /","",$pcon);
$pcon = preg_replace("/\r\n/","",$pcon);
$pcon = str_replace(chr(13),"",$pcon);
$pcon = str_replace(chr(10),"",$pcon);
$pcon = str_replace(chr(9),"",$pcon);
return $pcon;
}
函數(shù)二:
function select_search($name,$tb,$fid){
global $db;
$title="<select name=".$name."><option value= >所有</option>";
$r = $db->get_one("SELECT option_value FROM {$db->pre}fields WHERE name='$name' and tb='$tb'");
$option_value=loseSpace($r["option_value"]);
$ps = split("\*", $option_value);
#var_dump($matchs);
foreach ($ps as $s){
//以*分割1|可用*=> 1, 可用
if(!$s){
continue;
}
list($num,$word) = split("\|", $s);
$result[$num] = $word;
}
foreach($result as $n => $v)
{
if ($n==$fid){
$title .=" <option value=".$n." selected>".$v."</option>";
}
else{
$title .=" <option value=".$n.">".$v."</option>";
}
}
$title .="</select>";
return $title;
}
第一個(gè)函數(shù)的意思是過濾空格回車
第二個(gè)函數(shù)是根據(jù) name(自定義字段) tb(所屬模型) $fid(當(dāng)前所選ID)生成下拉列表。
第二步:
在module/sell/search.inc.php中的$day = isset($day) ? intval($day) : 0;下插入
$chengse = isset($chengse)?intval($chengse):0;
在if($vip) $condition .= " AND vip>0";下加入
if($chengse) $condition .= " AND chengse=$chengse";
然后在模板文件中使用:
{select_search(chengse,sell,$chengse)}
- destoon實(shí)現(xiàn)調(diào)用熱門關(guān)鍵字的方法
- destoon實(shí)現(xiàn)資訊信息前面調(diào)用它所屬分類的方法
- destoon實(shí)現(xiàn)首頁顯示供應(yīng)、企業(yè)、資訊條數(shù)的方法
- destoon實(shí)現(xiàn)公司新聞詳細(xì)頁添加評(píng)論功能的方法
- destoon數(shù)據(jù)庫表說明匯總
- destoon實(shí)現(xiàn)商鋪管理主頁設(shè)置增加新菜單的方法
- destoon安全設(shè)置中需要設(shè)置可寫權(quán)限的目錄及文件
- destoon整合ucenter后注冊(cè)頁面不跳轉(zhuǎn)的解決方法
- destoon整合UCenter圖文教程
- destoon調(diào)用自定義模板及樣式的公告欄
- destoon復(fù)制新模塊的方法
- destoon實(shí)現(xiàn)調(diào)用當(dāng)前欄目分類及子分類和三級(jí)分類的方法
相關(guān)文章
Laravel框架執(zhí)行原生SQL語句及使用paginate分頁的方法
這篇文章主要介紹了Laravel框架執(zhí)行原生SQL語句及使用paginate分頁的方法,以類函數(shù)的形式給出了Laravel框架執(zhí)行原生SQL語句以及paginate分頁的相關(guān)操作技巧,需要的朋友可以參考下2018-08-08
Laravel 創(chuàng)建指定表 migrate的例子
今天小編就為大家分享一篇Laravel 創(chuàng)建指定表 migrate的例子,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧2019-10-10
PHP數(shù)組實(shí)際占用內(nèi)存大小原理解析
這篇文章主要介紹了PHP數(shù)組實(shí)際占用內(nèi)存大小原理解析,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下2020-12-12
thinkPHP實(shí)現(xiàn)MemCache分布式緩存功能
這篇文章主要介紹了thinkPHP實(shí)現(xiàn)MemCache分布式緩存功能的方法,結(jié)合實(shí)例形式分析了thinkPHP通過修改CacheMemcache.class.php源文件實(shí)現(xiàn)分布式緩存功能的具體實(shí)現(xiàn)技巧,需要的朋友可以參考下2016-03-03
Django 標(biāo)簽篩選的實(shí)現(xiàn)代碼(一對(duì)多、多對(duì)多)
這篇文章主要介紹了Django 標(biāo)簽篩選的實(shí)現(xiàn)代碼(一對(duì)多、多對(duì)多),本文給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2018-09-09
yii2.0框架使用 beforeAction 防非法登陸的方法分析
這篇文章主要介紹了yii2.0框架使用 beforeAction 防非法登陸的方法,結(jié)合實(shí)例形式分析了yii2.0框架中beforeAction的基本原理、用法及防止非法登陸的相關(guān)操作技巧,需要的朋友可以參考下2019-09-09

