eits Posted December 19, 2007 Share Posted December 19, 2007 Hi, I have a page called page 1 with checkboxes on it. The value of each checkbox is <?php echo $row_rsquotes['item_id']; ?> . Using a loop I fetch each record from a MySQL database and so each checkbox should have the item_id as a value if it is checked. Could anybody give me an example of code I could put on the page which the form posts to in order to get each item_id and echo them? I would be really greatful!!! Quote Link to comment Share on other sites More sharing options...
rajivgonsalves Posted December 19, 2007 Share Posted December 19, 2007 post more of your code... your while loop then I'll modify it Quote Link to comment Share on other sites More sharing options...
trq Posted December 19, 2007 Share Posted December 19, 2007 Provided you named your checkbox's using an array. eg; <input type="checkbox" name="cb[]" value="<?php echo $row_rsquotes['item_id']; ?>" Then to simply echo the checkboxes that where checked on the recieving page... <?php if (isset($_POST['submit'])) { foreach($_POST['cb'] as $checked) { echo $checked . "<br />"; } } ?> Does this help? Quote Link to comment Share on other sites More sharing options...
eits Posted December 19, 2007 Author Share Posted December 19, 2007 Provided you named your checkbox's using an array. eg; <input type="checkbox" name="cb[]" value="<?php echo $row_rsquotes['item_id']; ?>" Then to simply echo the checkboxes that where checked on the recieving page... <?php if (isset($_POST['submit'])) { foreach($_POST['cb'] as $checked) { echo $checked . "<br />"; } } ?> Does this help? This worked great. Thanks!!!! Quote Link to comment Share on other sites More sharing options...
eits Posted December 19, 2007 Author Share Posted December 19, 2007 OK! I'm trying to get the selected boxes (which I can now do). However from the item_id I want to be able to move all matching fields from table 1 to table 2 in mysql. Currently I have: "INSERT IGNORE INTO orders (item_quant, item_type, item_desc, quote_id, comp_id, description) SELECT (item_quant, item_type, item_desc, quote_id, comp_id, description) FROM quote" Which is in the loop. But it doesn't work I keep getting Operand should contain 1 column(s) Quote Link to comment Share on other sites More sharing options...
richardw Posted December 19, 2007 Share Posted December 19, 2007 From that code it looks like you are not parsing the checkbox array prior to your insert statement 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.