2

我环顾四周,尝试了一些事情,但我似乎无法让它工作......有人可以帮忙吗?

$typeall = " ('House','Condo','Loft','Townhouse','Land')";

$rs = mysql_query("SELECT * FROM 'houses' WHERE and category IN " .$typeall); 

不工作

但如果我输入

$rs = mysql_query("SELECT * FROM 'houses' WHERE and category IN ('House','Condo','Loft','Townhouse','Land')"); 

它工作完美,为什么?

谢谢。

4

3 回答 3

0

尝试这个:

$typeall = "'House','Condo','Loft','Townhouse','Land'";

$rs = mysql_query("SELECT * FROM 'houses' WHERE and category IN (".$typeall.")");

可能是变量 $typeall 在括号中不起作用。

于 2013-04-05T12:25:44.700 回答
0

不要引用表名,并删除额外的and

$typeall = " ('House','Condo','Loft','Townhouse','Land')";
$rs = mysql_query("SELECT * FROM houses WHERE category IN " .$typeall);
于 2013-04-05T12:27:56.823 回答
0

您应该删除and

WHERE and category IN ...

进入:

WHERE category IN ...
于 2013-04-05T12:23:21.570 回答