Blackhorse.
If your server or your hosting has a PHP that is configured with [man]PDO[/man] + mysql
you can do what you describe with very little code.
PDO with mysql, sqlite or any other database has many good things to offer.
You will find methods, functions that normal [man]MySQL[/man] can not do.
Compared to PDO the php MySQL is a bit old and almost outdated.
I tested this code at my own Apache SERVER
so I know it works perfectly well
<?php
$host = "localhost";
$user = "dbuser";
$pass = "dbpass";
$dbnm = "database name";
// Connect to PDO MySQL
$dsn = "mysql:dbhost=$host;dbname=$dbnm";
$db = new PDO($dsn, $user, $pass);
$stmt = $db->prepare("SELECT id FROM member");
$stmt->execute(); // execute the prepared query
// FETCH one COLUMN from ALL rows in result IN one operation into array
// then implode array into one LINE using Comma+space between
$line = implode( ', ', $stmt->fetchAll (PDO::FETCH_COLUMN) );
// Test display the string
echo $line; //"1, 2, 3, 4, 5, 6, 7, 8, 9, 10"
exit('<hr />done!');
?>