多个条件在选择查询PHP myadmin MYSQL一个条件不起作用

时间:2017-04-06 05:59:57

标签: php mysql

    $_SESSION['post'] = array($_SESSION['gender'],$_SESSION['star'],$_SESSION['caste'],$_SESSION['marital'],$_SESSION['salary'],$_SESSION['education'],$_SESSION['from'],$_SESSION['to'],$_SESSION['district'],$_SESSION['country_liv']);
    $post=$_SESSION['post'];
 echo $post[9]; //printing the country value
$page = (int)(!isset($_GET["page"]) ? 1 : $_GET["page"]);
if ($page <= 0) $page = 1;


$per_page = 5; // Set how many records do you want to display per page.
$startpoint = ($page * $per_page) - $per_page;

$statement = "`tbl_member` where member_id!=$member_id  AND TIMESTAMPDIFF(YEAR, dob, CURDATE())>='$post[6]' AND 
    TIMESTAMPDIFF(YEAR, dob, CURDATE())<='$post[7]' AND gender Like '$post[0]%' AND star LIKE '%$post[1]%' AND caste LIKE '%$post[2]%' AND  mari_status LIKE '%$post[3]%' AND education LIKE '%$post[5]%' AND city_town LIKE '$post[8]%' AND month_income LIKE '%$post[4]%' AND country_liv LIKE '%$post[9]%'"; 


  $results=mysqli_set_charset($conDB, "utf8");
$results = mysqli_query($conDB,"SELECT * FROM {$statement} LIMIT {$startpoint} , {$per_page}");

现在我编辑了...... 我的所有编码都请帮助我....

我想在结果中显示特定国家....

我可以获得用户输入但是当我使用此查询时它无法正常工作.. 现在我编辑了...... 我的所有编码都请帮助我....

我想在结果中显示特定国家....

我可以获得用户输入但是当我使用此查询时它无法正常工作..

1 个答案:

答案 0 :(得分:0)

I'M changed the statement this :    

$statement = "`tbl_member` where member_id!=$member_id  AND TIMESTAMPDIFF(YEAR, dob, CURDATE())>='$post[6]' AND 
        TIMESTAMPDIFF(YEAR, dob, CURDATE())<='$post[7]' AND gender Like '$post[0]%' AND star LIKE '%$post[1]%' AND caste LIKE '%$post[2]%' AND  mari_status LIKE '%$post[3]%' AND education LIKE '%$post[5]%' AND city_town LIKE '$post[8]%' AND month_income LIKE '%$post[4]%' AND country_liv LIKE '%$post[9]%'"; 

到此:

$statement = "`tbl_member` where month_income LIKE '%$post[4]%' AND TIMESTAMPDIFF(YEAR, dob, CURDATE())>='$post[6]' AND 
    TIMESTAMPDIFF(YEAR, dob, CURDATE())<='$post[7]' AND  member_id!=$member_id AND country_liv LIKE '%$post[9]%' AND gender Like '$post[0]%' AND star LIKE '%$post[1]%' AND caste LIKE '%$post[2]%' AND  mari_status LIKE '%$post[3]%' AND education LIKE '%$post[5]%' AND city_town LIKE '$post[8]%' "; 

谢谢各位朋友......为我工作