Create Comma Seperated List from MySQL PHP -


i have list of users in table. how go taking list , returning 1 php variable each user name separated comma?

you generate comma-separated list query:

select group_concat(username) mytable 

or else fetch rows , join them in php:

$sql = "select username mytable"; $stmt = $pdo->query($sql); $users = array(); while ($username = $stmt->fetchcolumn()) {     $users[] = $username; } $userlist = join(",", $users); 

Comments

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -