jipacek Posted March 26, 2008 Share Posted March 26, 2008 Hallo there ! Can you please help me with this simple thing I can't make work or understand: mysql_connect('localhost', 'jipak', 'password'); mysql_select_db('contacts'); mysql_query('SELECT name FROM contacts'); $result = mysql_query('SELECT name FROM contacts'); $row = mysql_fetch_array($result); I would like to load data from sql instead of writing it manually like this: $DataArr = array("Some Notes on Jeff.", "Info on Amy", "Facts on Bob.", "Some more info on Jimmy","Some gossip about Steve."); Link to comment https://forums.phpfreaks.com/topic/98030-loading-array-with-sql-results/ Share on other sites More sharing options...
rhodesa Posted March 26, 2008 Share Posted March 26, 2008 How about this <?php mysql_connect('localhost', 'jipak', 'password'); mysql_select_db('contacts'); $result = mysql_query('SELECT name FROM contacts'); $DataArr = array(); while($row = mysql_fetch_array($result)){ $DataArr[] = $row['name']; } ?> Link to comment https://forums.phpfreaks.com/topic/98030-loading-array-with-sql-results/#findComment-501591 Share on other sites More sharing options...
wildteen88 Posted March 26, 2008 Share Posted March 26, 2008 Duplicate post. You already opened the same topic here Thread locked. Link to comment https://forums.phpfreaks.com/topic/98030-loading-array-with-sql-results/#findComment-501595 Share on other sites More sharing options...
Recommended Posts