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

ruby - When to use an ORM (Sequel, Datamapper, AR, etc.) vs. pure SQL for querying -

php - PHPDoc: @return void necessary? -

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