Hi all
How to show a radio button checked with value from the database.
Thanks in advance
iijb
[SOLVED]MySql data into a radio button
Moderator: General Moderators
[SOLVED]MySql data into a radio button
Last edited by iijb on Fri May 21, 2010 1:57 am, edited 1 time in total.
- Jonah Bron
- DevNet Master
- Posts: 2764
- Joined: Thu Mar 15, 2007 6:28 pm
- Location: Redding, California
Re: MySql data into a radio button
Something along these lines...
By the way, PHP questions belong in the PHP Code forum 
Code: Select all
<input type="radio" name="aradiobutton" value="value1"<?php echo ($db_column == 'value1') ? ' checked=""'; ?> />
<input type="radio" name="aradiobutton" value="value2"<?php echo ($db_column == 'value2') ? ' checked=""'; ?> />
<input type="radio" name="aradiobutton" value="value3"<?php echo ($db_column == 'value3') ? ' checked=""'; ?> />
<!-- etc. etc. -->MySql data into a radio button
Thanx Jonah Bron,
This line of code worked for me
Regards
iijb
This line of code worked for me
Code: Select all
<input type="radio" name="aradiobutton" value="value1" <?php if($db_column == value1') echo 'checked="checked"'; ?> />iijb