Avatar of nascent1
nascent1Flag for Canada asked on

populate radio box from database

I'm creating a form to edit previously entered entries and would like to have the radio box "ticked" to show the entry that is stored in the db. Is it possible to do that? "Canadian" is entered as the value in the "importance" field, in case that matters.


print "<div class='row'><label for='importance'>Canadian: </label>";
print "<input type='radio' id='importance' name='importance' value='$getentry3[importance]'/><br /></div>";

Open in new window

PHP

Avatar of undefined
Last Comment
nascent1

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
gamebits

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
SOLUTION
brad2575

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
brad2575

gamebits, beat me to it, but he can reduce the code if he just puts the if check in the input box to print "checked" similar to what I have above.  So he does not have to have to have as many lines of code to do this.
ASKER
nascent1

Thanks to both of you for responding. Unfortunately none of the provided code is working. Gamebits' code gives a blank page. brad2575's code (both versions) returns the radio box as checked, whether the field is empty or contains "Canadian". I do need to check for the value.

brad2575, you mentioned not know what language I'm using and I'm using PHP (and mysql).
ASKER
nascent1

I got it working :) ... I split the points between you as you both were so close in terms of response times and also because I used information provided by each of you. Hope this is ok and thanks for the help.
Your help has saved me hundreds of hours of internet surfing.
fblack61