what I am trying to do is setup a mysql query which uses an array in the
"where"-statement, like
"select * from example where id = $array[1]"
The array consist of a long list of integers which should all be looped
through. Any suggestions?
Cheers
Roman
You can do it with an IN () crtierion...
e.g.
$idlist = array(3,4,5,8,22,42);
$query = "select * from example where id in('";
$query .= join("', '", array_values($idlist));
$query .= "') order by somefield;";
$result = mysql_query($query, $linkid);...
$query will come out as something like
select * from example
where id in
('3', '4', '5', '8', '22', '42');
It may be, though, that you could do this with a join
somewhere in your database....
--
Matt Mitchell - AskMeNoQuestions
Dynamic Website Development and Marketing
http://www.askmenoquestions.co.uk/
$query = 'SELECT * FROM example WHERE id IN (' .
implode (',', $array) .
')';
Cheers,
NC