Retrieve values from checkboxes
| From: | shaun | Date: | Mon, 24 Mar 2003 13:06:45 +0000 |
| Subject: | Retrieve values from checkboxes | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-140844@lists.php.net to get a copy of this message | ||
Hi,
I have some checkboxes on my form and am using the following code to
populate it. The box will be checked if the user is allocated to the
project. My problem is if I uncheck a checkbox and send the form I don't
know what the $project_id is as it returns zero, so I cant delete the
corresponding record, is there a way around this?
while($j < $num){
$project_id = mysql_result($result, $j, Project_ID);
$project_name = mysql_result($result, $j, Project_Name);
echo '<tr>
<td height="30">'.$project_name.':</td>
<td><input name="'.$project_id.'" type="hidden"
value="0">
<input name="'.$project_id.'" type="checkbox"
value="'.$project_id.'" ';
$k = 0;
while ($k < $num_elements){
if ($project_id == $project_id2[$k]){
echo 'checked';
}
$k++;
}
echo '></td>
</tr>';
$j++;
}