jakatu Posted July 24, 2008 Share Posted July 24, 2008 I am trying to get an array of all of the values in a column in a table in my database. can anybody tell me how to do this? Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted July 24, 2008 Share Posted July 24, 2008 Cycle through the results and add to the array each time you do: <?php $sql = "SELECT field FROM table"; $result = mysql_query($sql) or trigger_error(mysql_error(),E_USER_ERROR); $array = array(); while($row = mysql_fetch_assoc($result)){ $array[] = $row['field']; } print_r($array); ?> Quote Link to comment Share on other sites More sharing options...
jakatu Posted July 24, 2008 Author Share Posted July 24, 2008 Thanks Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.