php - change my output format -


my php code :

$q = $db->query("select username users limit 3"); $users = array(); while($row = $db->fetchall($q)) {     $users[] = $row; }   foreach($users $user) {   echo $user['username'].'<br>';  } 

and output be

nilsen michael sam 

does possible change output format nilsen,michael,sam without start foreach ?

any idea please ?

thank you.

while($row = $db->fetchall($q)) // fetchall wired here, since result, asume that's right {     $users[] = $row['username']; } 

then use:

echo join(',' $users); 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -