siamiam Posted July 10, 2009 Share Posted July 10, 2009 This is the code I currently have. $result = mysql_query("SELECT DISTINCT city, state FROM exp_weblog_data"); while($row = mysql_fetch_array($result)) { echo $row['city'] . ", " . $row['state']; echo "<br />"; } It outputs something "New York, NY". I need to take that information a split it between two arrays like the following (for an autosuggest script)... $city = array( "New York", "Los Angeles", "Miami" ); $state = array( "NY", "CA", "FL" ); I've been going in circles trying to figure it out on my own. Any direction would be greatly appreciated. Thanks Link to comment https://forums.phpfreaks.com/topic/165542-solved-query-db-and-split-results-between-two-arrays/ Share on other sites More sharing options...
Psycho Posted July 10, 2009 Share Posted July 10, 2009 $result = mysql_query("SELECT DISTINCT city, state FROM exp_weblog_data"); while($row = mysql_fetch_array($result)) { echo $row['city'] . ", " . $row['state']; echo "<br />"; $cities[] = $row['city']; $states[] = $row['state']; } Link to comment https://forums.phpfreaks.com/topic/165542-solved-query-db-and-split-results-between-two-arrays/#findComment-873176 Share on other sites More sharing options...
siamiam Posted July 10, 2009 Author Share Posted July 10, 2009 Thank you so much for taking the time to help. I really appreciate it. Funny, something so small had me hung up for so long. Link to comment https://forums.phpfreaks.com/topic/165542-solved-query-db-and-split-results-between-two-arrays/#findComment-873188 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.