You would like to repopulate the selects and checkboxes in your form from the database? Want the previously selected options to be shown and checkboxes to have those damn ticks? Check this out....
Ok try this function....
function check($key,$value,$return) {
if ($key == $value)
return $return;
}
Then if you have a checkbox put this.....
echo "<p>State<select class=\"state\" name=\"state\">\n";
echo "<option value=\"Queensland\" ".check("Queensland",$_POST["state"],"selected") ." >Queensland</option>\n";
echo "<option value=\"New South Wales\" ".check("New South Wales",$_POST["state"],"selected"). " >New South Wales</option>\n";
If you want to repopulate selects use this....
echo "<p>State<select class=\"state\" name=\"state\">\n";
echo "<option value=\"Queensland\" ".check("Queensland",$state,"selected") ." >Queensland</option>\n";
echo "<option value=\"New South Wales\" ".check("New South Wales",$state,"selected"). " >New South Wales</option>\n";
I hope this helps, after weeks of hunting out long ways this was given by a guy called Markey Coates at Codewalkers. Cool ay.
Ciao
🆒