A Radio button question

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
PastorHank
Forum Contributor
Posts: 117
Joined: Sat Jun 03, 2006 7:58 am
Location: Texas Hill Country

A Radio button question

Post by PastorHank »

In my database I have a field that shows the status of a person. It has a single character "A" for active, "I" for inactive. What I am trying to do is when a person's record is retrieved if the status is "A" i want to show a radio button with the label 'Active' as checked. If I understand things correctly the 'value' of a radio button is the label and not if it's checked or unchecked, is that correct and if so, how do I tell the radio button to show itself as checked? I've found lots of examples on putting a value on the screen but nothing about what I'm trying to do.

thanks
Reviresco
Forum Contributor
Posts: 172
Joined: Tue Feb 19, 2008 4:18 pm
Location: Milwaukee

Re: A Radio button question

Post by Reviresco »

Code: Select all

<input type="radio" name="status" value="active"<?php if($status == 'A') { echo ' checked="checked"';}?> />
PastorHank
Forum Contributor
Posts: 117
Joined: Sat Jun 03, 2006 7:58 am
Location: Texas Hill Country

Re: A Radio button question

Post by PastorHank »

Reviresco wrote:

Code: Select all

<input type="radio" name="status" value="active"<?php if($status == 'A') { echo ' checked="checked"';}?> />
that's way too simple :) thank you
Post Reply