Hello,
I want to pass an array through a URL, then select data in my database from those values.
I have this URL:
../elements_by_id.php?id[]=1&id[]=2&id[]=5
Then I use this code:
- to produce the array and from that a mysql select statement.PHP Code:
$id = array();
$id = $_GET{'id'};
$id_select="";
$count = count($id);
$incr = 0;
foreach ($id as $ids) {
$id_select.="$ids";
$incr = $incr + 1;
if ($count = $incr) {$comma = ", ";}
else {$comma = "";}
$id_select.="$comma";
}
The idea is that the $id_select should end up having this value:
"1, 2, 5" (*)
- but i appears to be empty. Can anyone see what I am doing wrong?
(*) Will be using this in an mysql statement like this:
"select * from mytable where id in (1, 2, 5)"
Bookmarks