我已经尝试了此代码的所有不同类型的变体,但无法使其正常工作,有人能指出我正确的方向吗?
if(isset($_GET['s']) And isset($_GET['o'])) {
if(strip_tags(htmlspecialchars($_GET['s'])) === 's') $sortingby = 'sender';
if(strip_tags(htmlspecialchars($_GET['s'])) === 't') $sortingby = 'title';
if(strip_tags(htmlspecialchars($_GET['s'])) === 'd') $sortingby = 'timestamp';
if(strip_tags(htmlspecialchars($_GET['o'])) === 'a') $orderingby = 'ASC';
if(strip_tags(htmlspecialchars($_GET['o'])) === 'd') $orderingby = 'DESC';
echo '<br />';
echo $sortingby;
echo $orderingby;
}
$stmt = $pdo->prepare("SELECT * FROM messages WHERE
receiver = :id AND rhide = 0
ORDER BY :sortingby :orderingby
");
$stmt->execute(array(
':id'=>$id,
':sortingby'=>$sortingby,
':orderingby'=>$orderingby
));
$messages = $stmt->fetchAll(PDO::FETCH_ASSOC);
当我回显变量时,变量被正确分配,看起来我的内容被忽略了