Solarpitch Posted July 10, 2008 Share Posted July 10, 2008 Hi, I have a list of check boxes on my page as follows... <input type='checkbox' name='71' value='71'>Cappuccino Oak<br> <input type='checkbox' name='61' value='61'>Cityline Black White<br> <input type='checkbox' name='62' value='62'>Oiled City Beige Latte<br> <input type='checkbox' name='63' value='63'>Trendline Merbau<br> <input type='checkbox' name='64' value='64'>Trendline Natural<br> <input type='checkbox' name='65' value='65'>Trendline Light<br> <input type='checkbox' name='66' value='66'>Natural Masari<br> This is part of a form. What I'm trying to do is catch all the ones that the user has ticked then save the value id to a DB table. Saving it to a table and that should be fine, its just how to I get all the ones the user has ticked when the form is submitted and send them to the database? So Say the last 3 were ticked, I want to write 64, 65 and 66 to the database. Just having trouble with the logic of this really. Quote Link to comment Share on other sites More sharing options...
LooieENG Posted July 10, 2008 Share Posted July 10, 2008 if ( isset($_POST['61']) ) { // box 61 is set, do stuff } Quote Link to comment Share on other sites More sharing options...
Solarpitch Posted July 10, 2008 Author Share Posted July 10, 2008 Thanks man but I dont think that will work. The values are not hard coded, there taken from a database and besides, I'd have over 5000 if statements if I was to do that Might have to use a loop but not sure how :'( Quote Link to comment Share on other sites More sharing options...
LooieENG Posted July 10, 2008 Share Posted July 10, 2008 Friendly bump Quote Link to comment Share on other sites More sharing options...
Solarpitch Posted July 10, 2008 Author Share Posted July 10, 2008 Thanks.. I'm still banging away at it here! Quote Link to comment Share on other sites More sharing options...
DarkWater Posted July 10, 2008 Share Posted July 10, 2008 <input type='checkbox' name='checked[]' value='71'>Cappuccino Oak<br> <input type='checkbox' name='checked[]' value='61'>Cityline Black White<br> <input type='checkbox' name='checked[]' value='62'>Oiled City Beige Latte<br> <input type='checkbox' name='checked[]' value='63'>Trendline Merbau<br> <input type='checkbox' name='checked[]' value='64'>Trendline Natural<br> <input type='checkbox' name='checked[]' value='65'>Trendline Light<br> <input type='checkbox' name='checked[]' value='66'>Natural Masari<br> $_POST['checked'] will be a multi-dimensional array with all the checked boxes' values. Quote Link to comment Share on other sites More sharing options...
Solarpitch Posted July 10, 2008 Author Share Posted July 10, 2008 Thanks for that. I'll give it a go Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted July 10, 2008 Share Posted July 10, 2008 If you're updating a table, you can implode the array and use an IN clause to save you time. Quote Link to comment Share on other sites More sharing options...
DarkWater Posted July 10, 2008 Share Posted July 10, 2008 Yup. What are you trying to do with this data? 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.