radio button

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
spitfire_esquive
Forum Commoner
Posts: 37
Joined: Sun Nov 06, 2005 6:46 am

radio button

Post 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!
User avatar
dude81
Forum Regular
Posts: 509
Joined: Mon Aug 29, 2005 6:26 am
Location: Pearls City

Post 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

}
Post Reply