Destoon how to set custom search _ PHP Tutorial-php Tutorial

Source: Internet
Author: User
Destoon sets the custom search method. Step 1: In includeglobal. fun. add two function 1 to php: functionloseSpace ($ pcon) {$ pconpreg_replace (, $ pcon); $ pconpreg_replace (, $ pcon); $ pcon Step 1:

Add two functions to include/global. fun. php.

Function 1:

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;}

Function 2:

Function select_search ($ name, $ tb, $ fid) {global $ db; $ title ="All"; $ 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) {// split by * 1 | available * => 1, available if (! $ S) {continue;} list ($ num, $ word) = split ("\ |", $ s); $ result [$ num] = $ word ;} foreach ($ result as $ n =>$ v) {if ($ n ==$ fid) {$ title. ="". $ V ."";} Else {$ title. ="". $ V ."";}}$ Title. =""; Return $ title ;}

The first function is to filter spaces and press enter.

The second function generates a drop-down list based on name (custom field) tb (model) $ fid (currently selected ID.

Step 2:

$ Day = isset ($ day) in module/modules/search. inc. php )? Intval ($ day): 0; insert under

$chengse = isset($chengse)?intval($chengse):0;

Add the following under if ($ vip) $ condition. = "AND vip> 0 ";

if($chengse) $condition .= " AND chengse=$chengse";

Then use the following in the template file:

{select_search(chengse,sell,$chengse)}

Alias in include/global. fun. add two function 1 to php: function loseSpace ($ pcon) {$ pcon = preg_replace ("//", "", $ pcon ); $ pcon = preg_replace ("//", "", $ pcon); $ pcon =...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.