Help with a form...

Status
Not open for further replies.

matthew1471

New member
May 13, 2007
242
0
0
Bournemouth, UK.
I'm really struggling with this form...

formmz8.png



The form prints an incorrect category name, an option to select a correct category name, and a checkbox to update that cateogry.

I need to only pass the new categories which have the checkbox ticked. I'll then create the neccesary sql query to change the category in the db.

What would be the best way to do this? How do I loop through the form getting only the categories to be updated?
 


For example:

Code:
<input type="checkbox" name="sel_10" /> 
<input type="checkbox" name="sel_20" />
<input type="checkbox" name="sel_30" />
and then in PHP, i check for them using regular expressions:

Code:
foreach($_POST as $k=>$v) {
  preg_match("~sel_([0-9]+)~", $k, $r);
  if(count($r)) {
     $id = intval($r[1]);
     if($_POST['sel_'.$id] == 'on') {
         // checkbox is selected, do something... $id = checkbox number
     }
  }
}
 
Status
Not open for further replies.