没听懂楼主的意思…
如果需要多条件查询,可以运用嵌套查询,或者建立临时表,或者用PHP控制显示。

解决方案 »

  1.   

    $sql = "select * from tablename where 1=1 ";
    if($a != "")
    {
        $sql .= " and fileda = '$a' ";
    }
    if($b != "")
    {
        $sql .= " and filedb = '$b' ";
        if($b2 != "")
        {
            $sql .= " and (filedb = '$b' or filedb > '$b' ) ";
        }
    }
    if($c != "")
    {
        $sql .= " and fileda = '$c' ";
    }
    if($d != "")
    {
        $sql .= " and fileda = '$d' ";
    }
    if($e != "")
    {
        $sql .= " and fileda = '$e' ";
    }
    if($f != "")
    {
        $sql .= " and (filedb = '$f' or filedb > '$f' )";/***根据下拉框的内容进行调整***/
    }
    if($g != "")
    {
        $sql .= " and fileda = '$g' ";
    }
      

  2.   

    1、设表单中各select选项的value为数字,至少“学历要求”应为数字,由于有“以上”
    初值为0
    2、设各表单变量能正确读取,并按红字命名
    3、设各字段在同一表中,且与表单变量同名

    $query = "";
    if(!empty($a))
      $query .= "a like '%$a%' and ";
    if($b > 0) {
      if($b2)
        $query .= "b >= $b and ";
      else
        $query .= "b = $b and ";
    }
    if($c > 0)
        $query .= "c = $c and ";
    if($d > 0)
        $query .= "d = $d and ";
    if($e > 0)
        $query .= "e = $e and ";
    if($f > 0)
        $query .= "f = $f and ";
    if($g > 0)
        $query .= "g = $c and ";
    $query = "select * form tablename where ".substr($query,0,-5);
      

  3.   

    1、设表单中各select选项的value为数字,至少“学历要求”应为数字,由于有“以上”
    初值为0
    2、设各表单变量能正确读取,并按红字命名
    3、设各字段在同一表中,且与表单变量同名

    $query = "";
    if(!empty($a))
      $query .= "a like '%$a%' and ";
    if($b > 0) {
      if($b2)
        $query .= "b >= $b and ";
      else
        $query .= "b = $b and ";
    }
    if($c > 0)
        $query .= "c = $c and ";
    if($d > 0)
        $query .= "d = $d and ";
    if($e > 0)
        $query .= "e = $e and ";
    if($f > 0)
        $query .= "f = $f and ";
    if($g > 0)
        $query .= "g = $c and ";
    $query = "select * form tablename where ".substr($query,0,-5);