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!!! Link to comment https://forums.phpfreaks.com/topic/82317-code-snippet-anybody-please-checkbox-array-from-mysql-im-really-desperate/ 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 Link to comment https://forums.phpfreaks.com/topic/82317-code-snippet-anybody-please-checkbox-array-from-mysql-im-really-desperate/#findComment-418389 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? Link to comment https://forums.phpfreaks.com/topic/82317-code-snippet-anybody-please-checkbox-array-from-mysql-im-really-desperate/#findComment-418391 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!!!! Link to comment https://forums.phpfreaks.com/topic/82317-code-snippet-anybody-please-checkbox-array-from-mysql-im-really-desperate/#findComment-418422 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) Link to comment https://forums.phpfreaks.com/topic/82317-code-snippet-anybody-please-checkbox-array-from-mysql-im-really-desperate/#findComment-418425 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 Link to comment https://forums.phpfreaks.com/topic/82317-code-snippet-anybody-please-checkbox-array-from-mysql-im-really-desperate/#findComment-418597 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.