PHP SQL查询WHERE LIKE OR

时间:2014-10-06 15:13:21

标签: php mysql sql

对不好的头衔抱歉,无法想出更好的东西。

我有一个PHP查询到我的数据库,如:

$results = $db->query("SELECT shopname, image, price, location FROM shops WHERE shopname LIKE '%" . $_GET["shopname"] . "%'");

它工作正常,但我希望它更像:

$results = $db->query("SELECT shopname, image, price, location FROM shops WHERE shopname LIKE '%" . $_GET["shopname"] . "%' OR location LIKE '%" . $_GET["location"] . "%'");

但是“OR”部分以某种方式保留在一些引号中,从而给我:

注意:未定义的索引:位于 C <\ xampp \ htdocs \ harj \ app.php 的位置 13

我确信这只是我的一些疏忽,但经过很长一段时间在这里想知道什么是错的,任何帮助都会受到赞赏。

0 个答案:

没有答案
相关问题