0

前三个查询工作正常,但最后一个不是。第二个查询可以正常工作,$status !== '' 但最后一个$status !== '' 查询没有执行查询,任何人都可以帮助我

if (isset($_POST['go'])) {

     $status = $_POST[status];
     if ($status == 4){
             $status = '' ;
     }

    if ($topic == 100 && $subtopic == '' && $status == '' ) {
    $queryString = "select * from tblquiz where userid='$_SESSION[numericuserid]' LIMIT $start, $limit" ;
    $countString = "select * from tblquiz where userid='$_SESSION[numericuserid]'";
    }  // NOTE : THIS QUERY IS WORKING PERFECT

       elseif ($topic !== '' && $subtopic !== '' && $status !== '' ) {
    $queryString = "select * from tblquiz where qstatus=$status AND  qtopic='$topic[topicname]' AND subtopic='$_POST[subtopic]' AND userid='$_SESSION[numericuserid]' LIMIT $start, $limit" ;
    $countString = "select * from tblquiz where qstatus=$status AND  qtopic='$topic[topicname]' AND subtopic='$_POST[subtopic]' AND      userid='$_SESSION[numericuserid]'";
       }  // NOTE : THIS QUERY IS WORKING PERFECT

       elseif ($topic !== '' && $subtopic !== '' && $status == '' ) {
    $queryString = "select * from tblquiz where   qtopic='$topic[topicname]' AND subtopic='$_POST[subtopic]' AND userid='$_SESSION[numericuserid]' LIMIT $start, $limit" ;
    $countString = "select * from tblquiz where   qtopic='$topic[topicname]' AND subtopic='$_POST[subtopic]' AND userid='$_SESSION[numericuserid]'";
       }  // NOTE : THIS QUERY IS WORKING PERFECT


       elseif  ($topic == 100 && $subtopic == '' && $status !== '') {
    $queryString = "select * from tblquiz where qstatus= $status AND userid='$_SESSION[numericuserid]' LIMIT $start, $limit" ;
    $countString = "select * from tblquiz where qstatus= $status AND userid='$_SESSION[numericuserid]' ";
     }  **// NOTE : THIS QUERY IS NOT WORKING** 

}
4

2 回答 2

0
select * from tblquiz where qstatus= '$status' 

qstatus 缺少引号?

于 2012-09-01T02:23:08.790 回答
0

在您的 elseif 子句中,您检查 $status 是否为空,如果是则设置 $querystring 和 $countstring。这意味着您尝试查询

qstatus= AND

这应该产生了一个 SQL 错误。在尝试调试时打印出您的 sql 语句总是一个好主意。

于 2012-09-01T02:27:09.063 回答