How do I leave the radiobutton "checked" in PHP? I am having difficulty with this the name of the radiobutton is sex and I need to do a check in the database if the sex is 'M' it marks one of the radioButton sex otherwise it marks the other radioButton sex. I've done the SELECT and it returned the value of the other variables normally, I just want to know how to mark a radiobutton, my code is wrong? I already checked if the variable is receiving the sex value correctly and it is, the condition code is after the creation of the radioButton, I can not think of anything that is wrong, it can only be the way I'm dialing the radioButton.
<label>Sexo:</label><input type="radio" name="sexo" value="M"/>
<label>Masculino</label>
<input type="radio" name="sexo" value="F"/>
<label>Feminino</label>
if($vsexo == 'M')
{
echo "<script type='text/javascript'>sexo[0].checked = true;</script>";
}
else
{
echo "<script type='text/javascript'>sexo[1].checked = true;</script>";
}