php radio

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
User avatar
shiranwas
Forum Commoner
Posts: 53
Joined: Fri Jul 07, 2006 10:41 pm
Location: Colombo

php radio

Post by shiranwas »

hi,

i have a field called "rejected" in a table datatype enum('N','Y')
i want to check a radio button if the value is 'Y' how to do this

this is my html tag for radio button

<input name="optFrom" type="radio" value="Rejected" >



thanks

shiran
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Set the value attribute. Check it like another other form field.
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Post by pickle »

If you're checking or not checking the radio depending on the value in the database, you're going to need to set the 'checked' attribute.

Code: Select all

$checked = ($whateverYourDatabaseValue == 'Y') ? "checked = 'checked'" : '';

echo <<<RADIO
<input name = "optFrom" type = "radio" value = "Rejected" $checked />
RADIO;
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
User avatar
shiranwas
Forum Commoner
Posts: 53
Joined: Fri Jul 07, 2006 10:41 pm
Location: Colombo

Post by shiranwas »

it 's working
thanx
Post Reply