Page 1 of 1

radio button

Posted: Mon Jan 16, 2006 12:17 am
by spitfire_esquive
hello guys, hope you can help me. a form displays the data that is to be updated but i do not know what code needs to be written so that the value in the database will reflect in the radio button.

*this is a code snippet i wrote and it is just a simple text box that would reflect the value of htmlspecialchars($row['date_received']) ?>

Code: Select all

<td>Date Received<br><input type="text" name="upddate_received" value="<?php echo htmlspecialchars($row['date_received'] ) ?>">
what do i need to write so that i can do an equivalent on a radio box where the stored value is selected?

Code: Select all

<td>Resolved?<br>Yes <input type="radio" name="stat" value="Resolved">&nbsp;&nbsp;&nbsp;&nbsp;No<input type="radio" name="stat" value="Unresolved" CHECKED>
many thanks for the help!

Posted: Mon Jan 16, 2006 12:47 am
by dude81
There is only one way that I found when I came across the same situation

Code: Select all

$resolved=$row['dateresolved'];
if($resolved=='Resolved'){?>

Code: Select all

<input type="radio" checked="true" name="stat" value="Resolved"   >&nbsp;
No <input type="radio" name="stat" value="Unresolved" >&nbsp;

Code: Select all

}else if($resolved=='Unresolved'){

Code: Select all

<input type="radio"  name="stat" value="Resolved"   >&nbsp;
No <input type="radio" checked="true" name="stat" value="Unresolved" >&nbsp;

Code: Select all

}