Alrighty,
I haven't phped in a while (about a year), but it's slowly coming back to me...
I have a checkbox and when it is selected, I have an area in the db where it says 'checked' so I can echo that into the html and it'll be checked. Now, I'm having troubles unselecting. I'm thinking I should pass the variables in the url, but other suggestions are welcome.
My code:
<? if ($username=test) {
$result = mysql_query("SELECT * FROM basics WHERE $username=$username && $course='Composition I' && $checked='checked'");
$compchecked=checked;
} ?>
<? if($submit="submit")
{
if($compchecked==checked){
$id=$id;
echo "hellothere";
$type='communications';
$course='Composition I';
$checked='checked';
$username=$username;
$sqlquery = "INSERT INTO $table VALUES('$id','$type','$course','$checked','$username')";
$results = mysql_query($sqlquery);
}
if (!isset($compI)) {
echo "unchecked";
$unchecked='unchecked';
$sqlquery = "UPDATE $table ($checked) VALUES('$unchecked') WHERE $course='Composition I' && $username=$username";
$results = mysql_query($sqlquery);
}
echo $username;
}
?>
<form method="POST" action="<? $PHP_SELF?>">
<input type="checkbox" name="compI" value="yes" <?
echo $compchecked;
?>> Composition I<BR>
<input type="submit" name="submit">
</form>
When the page loads (and the box is checked), 'unchecked' still echoes. But if I uncheck it and then recheck it, submit, then the unchecked goes away.
Here it is live: http://www.cpanel37.gzo.com/~rsu/myrsu2.php
Any help would be appreciated. Thanx.