Here is what you need to do:
1. When setting up the column in your db you put the type as bool. 1 represents true and 2 represents false.
2. When you read the data from the page and want to save it into the db you have to convert the value to a 1 or zero. For example:
PHP Code:
<?php
extract($_POST);
if($chkVar == "on") { $chkVar = 1; } else { $chkVar = 0; }
?>
That will save it in the db for you. When you want to read the db you have to set the value in document.getElementById().checked like so:
PHP Code:
// after you have read the information from the db you need to echo the checkbox to the page either checked or not
<?php
// read the db
// coverting the 1 or zero to checked or not
if($chkVar == 1) {$chkVar = "checked"; } else {$chkVar = ""; }
// now you need to setup the form...
echo "<form blah blah>";
echo "<input type=\"checkbox\" name=\"chkVar\" $chkVar>";
?>
I think you get the idea... If not let me know.
Last edited by jim.thornton; 07-25-2006 at 05:01 PM..
|