I have what I think might be a relatively simple situation. I am using a series of checkboxes that represent various statuses. I write those statuses into a single field called "Status." in the database.
I have two problems.
1) If I select all 4 checkboxes, the data is written into the cell just fine. If a checkbox is not checked that I end up with an undefined variable error (one for each box not checked). (The other checked checkboxes sucessfully write into the database)
2) I need to be able to "read" the data back out of the database and display which checkboxes were previously checked. I have no code for this.
Here is my current starting code:
<form action="insert.php" method="POST">
<input type="checkbox" name="var1" value="P" />
<input type="checkbox" name="var2" value="V" />
<input type="checkbox" name="var3" value="R" />
<input type="checkbox" name="var4" value="Z" />
<input type="submit" name="">
<input type="reset" value="Reset this form">
</form>
Here is the contents of the insert.php file:
$status1=$_POST['var1'];
$status2=$_POST['var2'];
$status3=$_POST['var3'];
$status4=$_POST['var4'];
$statusarray = array($status1, $status2, $status3, $status4);
$status = implode($statusarray);
$query = "INSERT INTO chkbox VALUES ('','$status')";
$result=mysql_query($query);