$count=count($var); // counts the number of elements in ur array
$query=mysql_query("Select * FROM usersms WHERE id = '$var[$i]'");
echo "query failed";
I tried it but $name doesn't hold all the proper contents.
Select * FROM usersms WHERE id = '$var[$i]'
Let's say in the loop it searches for usersms WHERE id = '1'
Now in my database there may be 2 users with that id (in my db im not using this for users but that's irrelevant). In that case $name would only hold value for one of them.
No...No...$var is not an array, you just storing a array value. One more thing if you are going to check within while then why do you need foreach, remove that for each loop and just use directly as $var.