使用mysql数据库信息排序表的代码

时间:2013-06-05 07:35:07

标签: php mysql

我有以下代码用于根据状态对表信息进行排序。

$query = "SELECT * FROM affiliate_tasks WHERE username = '$_SESSION[username]'";

if( isset($_POST['sort-selection'] && $_POST['sort-selection'] != 'all' ) ) 
{
   $query .= " AND status = '". $_POST['sort-selection']."';" ;
}

$result = mysqli_query($con, $query);

当我运行网页时,它给了我这个错误:

Parse error: syntax error, unexpected T_BOOLEAN_AND, expecting ',' or ')' in /home/content/38/10473938/html/website/panda/affiliates/task.php on line 60

第60行如下:

if( isset($_POST['sort-selection'] && $_POST['sort-selection'] != 'all' ) ) {

我无法弄清楚代码有什么问题,任何帮助都会受到赞赏!

2 个答案:

答案 0 :(得分:2)

看起来好像你在那一行的错误位置有结束括号..

if( isset($_POST['sort-selection'] && $_POST['sort-selection'] != 'all' ) ) {

应该是

if( isset($_POST['sort-selection']) && $_POST['sort-selection'] != 'all' ) {

答案 1 :(得分:0)

结束括号中有语法错误

if( isset($_POST['sort-selection']) && $_POST['sort-selection'] != 'all' ) 
                                //^this one was missed and added at the end