I am trying to get my checkbox value to save on my dynamic created input, and I am failing miserably. Yes I've read a dozen or more tutorials online, but I cant find one that caters to a dynamic checkbox list... Please set me strait!!
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="checkboxForm">
<?php
$checkbox[] = array();
while($row = mysql_fetch_array($result)) {
$checked = isset($_POST['checkbox']) ? " checked" : "";
echo "<input name=\"checkbox[]\" type='checkbox' value='" . $row['first_name'] . "' $checked /> ";
echo $row['first_name'];
echo "<hr />";
//print_r( $_POST['checkbox']);
}
if(isset($_POST['checkbox']) && !empty($_POST['checkbox'])) {
foreach($_POST['checkbox'] as $checkbox){
echo $checkbox . "<br />";
} }
?>