zachatk1 Posted May 27, 2011 Share Posted May 27, 2011 Here's the code: $year_values = array('Any', 'N/A', '2000', '2001', '2002', '2003', '2004', '2005', '2006', '2007', '2008', '2009', '2010', '2011', '2012'); $db_year = explode(', ', $row['YEAR']); foreach($year_values as $year_value) { $selected_year = null; $year_label = $year_value; if(in_array($year_value, $db_year)) { $selected_year = ' checked="checked"'; $year_label = "<b>$year_value</b>"; } echo '<input type="checkbox" name="year" value="' . $year_value . '"' . $selected_year . ' />' . $year_label . ' '; } ?> [/code That pulls the data of the database and puts it in check boxes. The user can check/uncheck certain boxes but the problem is when it goes to the verify page it has only one value from the array that was selected. On the verify page it just checks if a box was checked and then implodes the array before submitting it into the database. [code] $year_s=implode($year,", "); So like I said there is only one value from the array when there should be as many as the user checks. So basically I believe the value isn't added to the array. Quote Link to comment https://forums.phpfreaks.com/topic/237686-not-adding-to-array/ Share on other sites More sharing options...
requinix Posted May 28, 2011 Share Posted May 28, 2011 The value isn't an array in the first place. To make arrays you need []s, like Quote Link to comment https://forums.phpfreaks.com/topic/237686-not-adding-to-array/#findComment-1221443 Share on other sites More sharing options...
zachatk1 Posted May 28, 2011 Author Share Posted May 28, 2011 WOW... duh. Can't believe I never saw that... thanks! Quote Link to comment https://forums.phpfreaks.com/topic/237686-not-adding-to-array/#findComment-1221446 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.