I was trying to get the list of usernames separated by comma(,) and I used this SQL:
$sql="select group_concat(concat(' ',username,' ')) as username from user";
$var=mysql_query($sql);
while($v=mysql_fetch_assoc($var)){ $variable=$v['username']; }
echo $variable;
Ignore the mysql_* function here.
The above SQL helped me to get the list of all user in the database and echo it but I got a problem when I used LIMIT 3 and/or ORDER BY rank at the end like:
$sql="select group_concat(concat(' ',username,' ')) as username from user ORDER BY rank LIMIT 3";
After I add ORDER BY.... there comes no change to the result.
Is there any way to fix the above code using ORDER BY rank LIMIT 3 at end of SQL? or is there any other method to do it?
Thanks in Advance!