我想知道如何通过数组获取所有字段值。
我有数组s
我的桌子是
id content
1 zahr
2 hai
.
.
.
and so on
$a = {2,3,4,5,43,32};
i have to take the contents by this id(from array "a").
i know, i can use "for" loop for getting each element from mysql.
but i would like to use any filters or any predefined function
谢谢并提前
答案 0 :(得分:6)
SELECT * FROM table WHERE id IN (2,3,4,5,43,32)
可以使用implode创建语句,如:
$myvar = '('.implode(',',$a).')';
然后
SELECT * FROM table WHERE id IN $myvar
答案 1 :(得分:1)
使用IN