如果参数与showall匹配,修改此查询以显示所有记录的最佳方法是什么,这是正常的做法:
if (isset($_GET['category']) && $_GET['category'] == 'showall') ... else ?
SELECT id, heading, category FROM table WHERE category = %s ORDER BY `date` DESC
答案 0 :(得分:0)
最容易的方法是:
if (isset($_GET['category']) && $_GET['category'] == 'showall'){
execute : SELECT id, heading, category FROM table ORDER BY `date` DESC
} else if(isset($_GET['category']) && $_GET['category'] != 'showall') {
execute : SELECT id, heading, category FROM table WHERE category = %s ORDER BY `date` DESC
}