本帖最后由 phpchuxuecainiao 于 2010-08-30 15:02:43 编辑

解决方案 »

  1.   

    <?php
    $wen1 = isset($_POST['wen1'])?$_POST['wen1']:(isset($_GET['wen1'])?$_GET['wen1']:"");
    $wen2 = isset($_POST['wen2'])?$_POST['wen2']:(isset($_GET['wen2'])?$_GET['wen2']:"");$where = "where 1";
    if(!empty($wen1) && !empty($wen2)){
        $where.= " and $wen1 like '%{$wen2}%'";
    }
    $sql = "SELECT count(*) as countnum FROM hotel_rizhi $where";
    $result = mysql_query($sql);
    while ($row = mysql_fetch_array($result)) {
        //printf("ID: %s  Name: %s", $row[0]);
        $countnum = $row['countnum'];
    }if($countnum == 0)
      die("<script>alert('查询的数据不存在');window.location='shuju.php';</script>");
    ?>