How to manage empty IN sql query?
you should not run the query when the $in is empty. I think what yoou need is something like this
$in = implode(',',$ids);if($in) { $query = "SELECT * FROM user where user_id IN ($in) "; } else { //alternate scenario here }
Edit
$in = implode("','",$ids); // generate like 1','2$query = "SELECT * FROM user where user_id IN ('$in') "; // if has 1','2 surrond it with quote make it IN('1','2') and if empty than IN('')