You first want to collect your values, which you fetch from your db, into an array. Then you want to implode() it.
while($result1=mysql_fetch_assoc($sql)){
$result[] = $result1['userId'];
}
echo implode(",",$result);
Right now in your code you simply explode one value into an array, but it can't split the string on the delimiter, so it just puts your value into the first array element.
Then imploding an array with only 1 element doesn't make much sense and you simply just output the value again in the while loop. So what your current code does right now is just:
while($result1=mysql_fetch_assoc($sql)){
echo $result1['userId'];
}
mysql_*functions in new code. They are no longer maintained and are officially deprecated. See the red box? Learn about prepared statements instead, and use PDO or MySQLi.