php - select where id IN (list) not working after list modified -


this seems simple issue, causing me ridiculous headache.

here query: select * table id in ($list);

lets list is: 1,2,3,4,5,6

on first execution of query, works great, retrieves requested rows. then, remove 1 value: 1,2,4,5,6

suddenly, query retrieves nothing.

i echo $list , $list displays 1,2,4,5,6

i replace in ($list) in (1,2,4,5,6) , works perfectly.

what missing?

heres code removes 1 value:

function removefromlist($id, $list){ $ider = ','.$id.','; if($list[strlen($list)-1] == ','){ if($list[0] != ','){     $list = ','.$list; } $list = str_replace($ider, ',', $list); if($list[strlen($list)-1] == ','){     $list[strlen($list)-1] = '';     } if($list[0] == ','){     $list[0] = '';   } } else { if($list[0] != ','){     $list = ','.$list; } $list = $list.','; $list = str_replace($ider, ',', $list); if($list[strlen($list)-1] == ','){     $list[strlen($list)-1] = '';     } if($list[0] == ','){     $list[0] = ''; } } return $list; } 

what happens if change query  select * table id in ('$list'); 

Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -