Jump to content

Code Snippet Anybody Please? Checkbox Array from MySQL! I'm really desperate!


eits

Recommended Posts

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!!!

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?

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!!!!

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)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.