所以我试图根据单击的提交按钮对 SQL 查询进行排序
我的排序选项:
echo "<form method='post' action adminview.php'>"
."<input type='submit' name='sort' value='Sort by Attempt ID'/><br />"
."<input type='submit' name='sort' value='Sort by Student ID'/><br />"
."<input type='submit' name='sort' value='Sort by lowest Score'/><br />"
."<input type='submit' name='sort' value='Sort by highest Score'/><br />"
."</form>";
当页面重新加载时,这里是检查单击哪个按钮的代码
switch($_POST['sort'])
{
case "Sort by Attempt ID":
$sortby = "attempt_id";
break;
case "Sort by Student ID":
$sortby = "student_id";
break;
case "Sort by lowest Score":
$sortby = "score";
break;
case "Sort by highest Score":
$sortby = "score desc";
break;
}
我的问题是,当页面重新加载时,它说排序是未定义的。
如果你好奇这里是 SQL 语句
$sqlstring = "select * from quizattempts order by '$sortby'";