I'm working on a bit of code to edit data from a database. On the original form (which I am mimicking) it has a radio button group with 6 options for days :
<label for="arrival">When will you arrive?</label><br />
<input type="radio" id="pre" name="arrival" value="pre"/>Pre-KG<br />
<input type="radio" id="wed" name="arrival" value="wed"/>Wednesday<br />
<input type="radio" id="thu" name="arrival" value="thu"/>Thursday<br />
<input type="radio" id="fri" name="arrival" value="fri"/>Friday<br />
<input type="radio" id="sat" name="arrival" value="sat"/>Saturday<br />
<input type="radio" id="sun" name="arrival" value="sun"/>Sunday<br />
I the put the value to the database after submission of the form. Now I am calling the data from the database and I want to have the correct radio button selected. Any suggestions on this? I can't seem to find it by searching...
values are coming from an sql query to my database using $row["arrival"] with a value of one of the values above...
Previously for a yes/no option I used...
if ($row["costyn"]==1){
echo '<input type="radio" name="costyn" value="1" checked>Yes<br>';
echo '<input type="radio" name="costyn" value="0">No<br>';
} else if ($row["costyn"]==0) {
echo '<input type="radio" name="costyn" value="1" >Yes<br>';
echo '<input type="radio" name="costyn" value="0" checked>No<br>';
}
There must be a cleaner way though.
checked, notselected.