tags:

views:

37

answers:

2

hi

i want to know how to get all fields value search by array.

i have array that s

my table is

  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

thanks and advance

+6  A: 
SELECT * FROM table WHERE id IN (2,3,4,5,43,32)

the statement could be created by using implode like:

$myvar = '('.implode(',',$a).')';

and then

SELECT * FROM table WHERE id IN $myvar
oezi
hey i am getting empty result if i use array.i can get if i give input directly like select * from details where id in(1)
zahir hussain
hey sorry i am getting the result..
zahir hussain
+1  A: 

use IN

Reigel