Page 1 of 1

Array, database... help!

Posted: Wed Jan 15, 2003 4:33 pm
by megaming
Hi,

I want to split some numbers that are seperated by commars (,) and put them into an array.

I then want to select each record from a database which has the same id as the numbers in the array.

I think this would be done by a split, then a for or a while.

I'm not sure though... can someone help me out?

Thanks!

Posted: Wed Jan 15, 2003 4:53 pm
by volka
if the numbers are separated by , the string is perfectly suited for expr IN (value,...) (http://www.mysql.com/doc/en/Comparison_Operators.html#IDX1118)
e.g.

Code: Select all

$query = 'SELECT field FROM table WHERE id IN ('.$numbers.')';