Canman2005 Posted May 25, 2008 Share Posted May 25, 2008 Hi all I have an array in my php code $aUsers = array( "Ädams, Egbert", "Zaun, Jillie", ); Is there anyway to populate the array with a SQL query such as $sql = "SELECT * FROM `members`"; $show = @mysql_query($sql,$connection) or die(mysql_error()); while ($row = mysql_fetch_array($show)) { print "name" } Any help would be smashing Thanks in advance Dave Link to comment https://forums.phpfreaks.com/topic/107142-query-in-array/ Share on other sites More sharing options...
pocobueno1388 Posted May 25, 2008 Share Posted May 25, 2008 If I understand what your wanting, try this: <?php $aUsers = array( "Ädams, Egbert", "Zaun, Jillie", ); $sql = "SELECT * FROM `members`"; $show = @mysql_query($sql,$connection) or die(mysql_error()); while ($row = mysql_fetch_array($show)){ $aUsers[] = $row['name']; } //new array with names added echo '<pre>',print_r($aUsers),'</pre>'; ?> Link to comment https://forums.phpfreaks.com/topic/107142-query-in-array/#findComment-549313 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.