glennn.php Posted July 2, 2010 Share Posted July 2, 2010 i have some form fields such as "rent", "elec", "gas", etc... where the values for these fields are stored in a db table with an item_id assigned to each item... using this: while ($row = mysql_fetch_array($result)) { echo $row['item_id'].": ".$row['amount']; } i'm not sure how to get the amounts for item_ids 13, 14, 15... into an array so that i can echo them elsewhere (in their respective textfields), 13 being "rent", 14 being "elec", etc... thanks for the help GN Quote Link to comment https://forums.phpfreaks.com/topic/206524-getting-results-into-an-array/ Share on other sites More sharing options...
Adam Posted July 2, 2010 Share Posted July 2, 2010 Do you ONLY want items 13, 14 & 15? Quote Link to comment https://forums.phpfreaks.com/topic/206524-getting-results-into-an-array/#findComment-1080299 Share on other sites More sharing options...
glennn.php Posted July 2, 2010 Author Share Posted July 2, 2010 no, there are 17 different forms i'd use this on, with a varying number of assigned items. one form has 24 values... Quote Link to comment https://forums.phpfreaks.com/topic/206524-getting-results-into-an-array/#findComment-1080302 Share on other sites More sharing options...
Adam Posted July 2, 2010 Share Posted July 2, 2010 Store the results into an array: $items = array(); while ($row = mysql_fetch_array($result)) { $items[$row['item_id']] = $row['amount']; } That you can reference the array later. Quote Link to comment https://forums.phpfreaks.com/topic/206524-getting-results-into-an-array/#findComment-1080310 Share on other sites More sharing options...
glennn.php Posted July 2, 2010 Author Share Posted July 2, 2010 beautiful. works like a champ. thanks, mr adam... Quote Link to comment https://forums.phpfreaks.com/topic/206524-getting-results-into-an-array/#findComment-1080317 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.