Php...... House Rental Practice

Source: Internet
Author: User

Multi-Criteria Query Search page, submitted to the current page processing

<?PHPinclude(".. /db.class.php ");$db=NewDB ();/*var_dump ($_post["qy"]);    Selected Area var_dump ($_post["ZLLX"]);    Selected lease Type Var_dump ($_post["FWLX"]); Selected house type Var_dump ($_post["Guanjianzi"]);*/ //input keyword//$sql = "SELECT * from house where area in (' Sakai ', ' Sanyi Temple ', ' Upper Uptown ')"; So you need to split the array into strings, with ', ' separated, using implode ("delimiter", Array) /c10>$VG= ""; $TJ 1= "1=1";$TJ 2= "1=1";$TJ 3= "1=1";$TJ 4= "1=1";//determines whether the passed value is empty, four conditions four timesif(!Empty($_post["QY"])){    $attr=$_post["QY"]; $str=implode("‘,‘",$attr);//split the array into strings, separated by ', '    Var_dump($str); $vjs= "area in (' {$str}‘)";//Quotation marks in a query statement are used to complete the quotes at both ends    }if(!Empty($_post["Zllx"])){    $attr=$_post["Zllx"]; $str=implode("‘,‘",$attr); $TJ 2= "Renttype in (' {$str}‘)"; }if(!Empty($_post["FWLX"])){    $attr=$_post["FWLX"]; $str=implode("‘,‘",$attr); $TJ 3= "Housetype in (' {$str}‘)"; }if(!Empty($_post["Key"])){    $GJZ=$_post["Key"]; $TJ 4= "KeyWord like '%{$GJZ}%‘"; $VG=$GJZ; }$ss= "Where {$TJ 1} and {$TJ 2} and {$TJ 3} and {$TJ 4}";?>
<!--form Content -<formAction= "zufang.php"Method= "POST">    <Div>Area:<inputtype= "checkbox"onclick= "Checkall (this, ' qy ')"/>Select All<!--This represents the button itself QY represents the classname of the following option -    </Div>      <Div>
<?PHP//Regional Options    $sqlqy= "SELECT distinct area from house"; $attrqy=$db->query ($sqlqy, 0, "Housedb"); //Var_dump ($attr);     foreach($attrqy  as $v)    {        Echo"<input type= ' checkbox ' value= ' {$v[0]} ' class= ' qy ' name= ' qy[] ' >{$v[0]} "; }    ?> </div><br/> <div>type of leasing:<input type= "checkbox" onclick= "Checkall (This, ' zllx ')"/>Select All</div> <div> <?PHP//Leasing Type Options    $sqlzl= "SELECT distinct Renttype from house"; $attrzl=$db->query ($sqlzl, 0, "Housedb"); //Var_dump ($ATTRLX);     foreach($attrzl  as $v)    {        Echo"<input type= ' checkbox ' value= ' {$v[0]} ' class= ' zllx ' name= ' zllx[] '/> {$v[0]} "; }    ?> </div><br/> <div>type of house:<input type= "checkbox" id= "Fwlxqx" onclick= "Checkall (This, ' fwlx ')"/>Select All</div> <div> <?PHP//Housing Type Options    $SQLFW= "SELECT distinct Housetype from house"; $ATTRFW=$db->query ($SQLFW, 0, "Housedb"); //Var_dump ($ATTRFW);     foreach($ATTRFW  as $v)    {        Echo"<input type= ' checkbox ' value= ' {$v[0]} ' class= ' fwlx ' name= ' fwlx[] '/> {$v[0]} "; }?> </div><br/>
 <!--keyword search box -    <Div>Key Words:<inputtype= "text"name= "Key"value= "<?php echo $vg;? > " />    </Div>    <BR/>    <inputtype= "Submit"value= "Search" /></form><BR/><!--House Rental Form -<Tablewidth= "100%"Border= "1"cellpadding= "0"cellspacing= "0"><TR><TD>Key words</TD><TD>Regional</TD><TD>Area</TD><TD>Rent</TD><TD>Type of Leasing</TD><TD>Type of House</TD></TR>
<?PHP$SQLSS= "SELECT * from House".$ss;//echo $SQLSS;$attrss=$db->query ($SQLSS, 0, "Housedb");foreach($attrss  as $v){        $RPG= "<span style= ' color:red ' >{$VG}</span> "; $STRG=Str_replace($VG,$RPG,$v[1]); Echo"<tr> <td>{$STRG}</td> <td>{$v[2]}</td> <td>{$v[3]}</td> <td>{$v[4]}</td> <td>{$v[5]}</td> <td>{$v[6]}</td> </tr>";}? ></table></body><script type= "Text/javascript" >functionCheckall (A,b) {    varXZ = a.checked;//find selection of the Select All button    varCK = Document.getelementsbyclassname (b);//find the checkbox corresponding to the Select all     for(vari=0; i<ck.length;i++) {Ck[i]. checked =XZ; }}</script>

Attention:

1. Multiple select buttons to implement the same function with one method, you need to pass the parameters to the method

Two parameters are passed in the above, this and classname

This represents the element itself, and classname represents the options for each selection

2. Stitching an array into a string with implode ("delimiter", Array)

Splitting a string into an array with explode ("delimiter", "string")

Delimiter to write well, you can write an example to see clearly and then write

Php...... House Rental Practice

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.