Multi-criteria query (check box condition)

Source: Internet
Author: User

The query will traverse the table, showing that the table is the same as before, not much, say, how to write check box conditions

One, traverse the contents of the check box, list name: The others are the same traversal method

<div> area: <input type= "checkbox"/> Select all </div>
<div> <?php $sqla = "SELECT distinct area from house"; Go to the area name $a = $db->query ($sqla); while ($qy = $a->fetch_row ()) { echo "<input type= ' checkbox ' name= ' quyu[] ' value= ' {$qy [0]} ' >{$ Qy[0]} "; } ? ></div>

Second, the preparation of the conditions: write one on it, and the others are almost

<?php $db = new mysqli ("localhost", "root", "123", "Housedb"); $TJ 1 = "1=1";   Permanent establishment//area conditions if (!empty ($_post["Quyu"]) && count ($_post["Quyu"]) >0)//determine if NULL {$quyu = $_post["Quyu"];  The array is stitched into the condition of the query: code in (', ', ', ', ', ')//array concatenation string $str = Implode ("', '", $quyu);//Query condition $TJ 1 = "area in (' {$str} ') ";  }

Three, JS full selection of the preparation

function Quanxuan (a) {var qx = document.getelementsbyclassname ("QX"); if (a.checked)   //Determine if the value of the property is selected {for (Var i=0;i <qx.length;i++)        {    Qx[i].setattribute ("Checked", "checked");  Add attribute}}else{for (var i=0;i<qx.length;i++) {    qx[i].removeattribute ("checked");   Remove attribute}}}        

 

Iv. Session Retention

1.session
Characteristics:
(1) Has default expiration time, about 15 minutes
(2) stored on the server, each person saves one copy
(3) can store any type of data


Usage:
Use the session to the top of the page need to add session_start ();
Assignment $_session["UID"]= "Zhangsan";
Value $_session["UID"];

2.cookie
Characteristics
(1) stored in the client's
(2) No expiry time
(3) Only data with string types can be stored


Usage:
Assignment: Setcookie ("UID", "Lisi");
Value: $_cookie["UID"];

 

  

  

Multi-criteria query (check box condition)

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.