Pass php array to MySQL IN clause

by Subramanian 2014-01-11 14:52:00

Pass php array to MySQL IN clause :

$uid=array(1,2,3,4,5,12,32);
$uid=join(',',$uid);

$getUserName = mysql_query("select uname from users_table where uid IN ($uid) order by uid");


Note : If you want to get the user name for single uid then you must also pass that single uid in array format. Like Below Code

$uid=array(13);
$uid=join(',',$uid);

$getUserName = mysql_query("select uname from users_table where uid IN ($uid) order by uid");
823
like
0
dislike
0
mail
flag

You must LOGIN to add comments