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


Code for sorting table using mysql database information

我有下面的代码,用于根据状态对表信息排序。

$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' ) ) {

我不知道代码出了什么问题,希望能得到任何帮助!

看起来好像你把右括号放在了那一行的错误位置。

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

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

右括号语法错误

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