gergy008 Posted June 20, 2010 Share Posted June 20, 2010 Hi everyone, Thanks for lookin at the thread I was wondering if I could have a little help echoing an array of all the users in my DB into a format of for example 'cow' , 'pigeon', 'giraffe' $sql='SELECT `login` FROM `users`;'; $run=$mysql_query($sql, $link); I do know that you need to use the while statement but I am not that confident in using it, It's completely blanked out of my head. Thanks in advance! PS. I will be working on it too, Please don't think I'm just shoving you a job under your nose because I can't be bothered to do it >_< Link to comment https://forums.phpfreaks.com/topic/205357-echo-a-php-array-into-a-format/ Share on other sites More sharing options...
Alex Posted June 20, 2010 Share Posted June 20, 2010 $sql = 'SELECT `login` FROM `users`;'; $run = mysql_query($sql, $link); $users = array(); while($row = mysql_fetch_assoc($run)) { $users[] = $row['username']; } echo "'" . implode("', '", $users) . "'"; Link to comment https://forums.phpfreaks.com/topic/205357-echo-a-php-array-into-a-format/#findComment-1074740 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.