// 0 = no and 1 = yes
if ($option == 0) {$checked = "";} else {$checked="checked"};
printf("<input type=\"checkbox\" name=\"name\" value=\"value\" %s>", $checked);
Dropdown code below...
<?php
$values[0] = "Newbie";
$values[1] = "Regular";
$values[2] = "Veteran";
// Put the call below in your form
xDropDown("status",$values,1);
// Put this function in your icommon.php file...
function xDropDown($name, $values, $default) {
// This function is called to display a drop down box
// $values is an array thats loaded prior to the calling of this function and
// contains a list of text will appear in the dropdown
printf("<select size=\"1\" name="%s">", $name);
for ($x=0;$x<count($values);$x++) {
if ($x == $default) {$selected = "checked";} else {$selected = "";}
printf("<option %s value=\"%s\">%s</option>",$selected, $x, $value[$x];
}
printf("</select>");
}
Then, after the user submits the form, $status will contain either 0, 1 or 2 and you insert this into the MySql db column.
Initially, prior to calling xDropDown, you can query the database and load the previously selected value into the $default var... This causes the drop down to initially display the chosen db value... I've got more...