Radio Buttons and Default Values

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
Adrianc333
Forum Newbie
Posts: 14
Joined: Sat Feb 17, 2007 5:44 am
Location: South Yorkshire, UK

Radio Buttons and Default Values

Post by Adrianc333 »

Hey,

I have done a quick search on the internet, and these forums before posting this.

Anyway, here's my question. :)

In my MySql DB, i have a field called "enabled", this is a INT.
In my script, i have Two Radio Buttons.

For example,

Enable this Function: (Button) Yes (Button) No

So, how would i get one of those Radio Buttons, to be checked, depending on the Value in my Enabled Field/Row? (1 or 0)

Any help would be greatly appreciated!

Thanks
Adrian
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post by s.dot »

Code: Select all

<input type="radio" name="somename"<?php if($row['enabled'] == 1){  echo ' checked'; } ?> />
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
Adrianc333
Forum Newbie
Posts: 14
Joined: Sat Feb 17, 2007 5:44 am
Location: South Yorkshire, UK

Post by Adrianc333 »

Thanks, i though it could be something like that.

I just have a bunch of them to do. :(
Post Reply