0
在我的查询中,我只想从id 1-3出现在结果中,而不是4-6。有没有其他方法可以做到这一点?php mysql for循环
beautician database table:
id_beautician name
1 a
2 b
3 c
4 d
5 e
6 f
我试图把下面的代码在MySQL查询
for($i=4; $i<=6; $i++) :
$q.$i = $db->query("SELECT * FROM beautician WHERE id_beautician='$i'");
$r.$i = $q.$i->fetch_assoc();
//echo $i;
endfor;
,但它给了我一个错误:
Object of class mysqli_result could not be converted to string
WHERE id_beautician(4,5,6) – 2011-04-14 12:31:28
请使用'$ db-> real_escape_string'或者至少将id转换为(int)。了解SQL注入! – cweiske 2011-04-14 12:47:34
@cweiske:因为有了一切设置。再次感谢 – tonoslfx 2011-04-14 12:57:59