mothra
10-20-2006, 06:04 AM
I've got a few pages where I'm using an array of check boxes in a form to update records in a mySQL table, php code looks like below (form code not shown)...
//Find each checked check box
foreach ($_POST['check_box_in_array'] as $check) {
if ($users == "") {
$users = "'$check'";
}else{
$users .= ",'$check'";
}
}
// Update the table
$sql = "UPDATE member_info SET myfield='myvalue', WHERE user_name in ($users)";
I'm sure some of you are familiar with this approach. Can anyone help me out with doing something similar, but rather than check boxes I want to use some input fields where the user can enter a value, I then need to find the record(s) in my table and use this value to modify each of them accordingly. I'm a little braindead and could use some help :)
This is what the line from my form code that creates the check box looks like...
printf (" <td style=\"width:100px;\"> <input type=\"checkbox\" name=\"check_box_in_array[]\" value=\"%s\"> </td>", $row["user_name"]);
The reference to $row["user_name"] is a record from my table. IF this isn't making sense I can just post the code, I think this is a common technique and was hoping someone would be familiar enough to help out.
//Find each checked check box
foreach ($_POST['check_box_in_array'] as $check) {
if ($users == "") {
$users = "'$check'";
}else{
$users .= ",'$check'";
}
}
// Update the table
$sql = "UPDATE member_info SET myfield='myvalue', WHERE user_name in ($users)";
I'm sure some of you are familiar with this approach. Can anyone help me out with doing something similar, but rather than check boxes I want to use some input fields where the user can enter a value, I then need to find the record(s) in my table and use this value to modify each of them accordingly. I'm a little braindead and could use some help :)
This is what the line from my form code that creates the check box looks like...
printf (" <td style=\"width:100px;\"> <input type=\"checkbox\" name=\"check_box_in_array[]\" value=\"%s\"> </td>", $row["user_name"]);
The reference to $row["user_name"] is a record from my table. IF this isn't making sense I can just post the code, I think this is a common technique and was hoping someone would be familiar enough to help out.