Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Radio Button Value 1

Status
Not open for further replies.

jgeddes

Programmer
Aug 3, 2001
18
US
I am using PHP and MySQL to store information into a database from a web page.

I can get the information into the database and I am able to retrieve it to edit, but I am need help with the radio buttons. I am able to put the current value of a field into a form field for display and edit, but how do I show which radio button is selected? Both buttons are vales for the same field.

Thanks.
 
I am not 100% sure, I understand your question, but I'll take a stab at it.

Here is how you would show a radio button being selected as the default value:

[tt]
<input type=&quot;radio&quot; name=&quot;button&quot; value=&quot;button1&quot; CHECKED>
[/tt]

Hope this helps.

-Vic

P.S. You could have also asked this in the HTML forum and gotten a better/faster reply. vic cherubini
krs-one@cnunited.com
 
Thanks for the help. I thought about putting it in the html forum, but it is not so much the code to enter, but the code to retrieve the value from the db.

FOr a text box, this is my code for entry:

<input type=&quot;Text&quot; name=&quot;assoc_price&quot;>

when the user modifies a record, the code looks like this, so that the current value is shown:

<input type=&quot;Text&quot; name=&quot;assoc_price&quot; value=&quot;<?php echo $assoc_price ?>&quot;>

My problem is with radio buttons, how do I show the value, or button, for the field?

Thanks again for the help.
 
I think you have to do some if/else testing
Code:
Button 1: <input type=&quot;radio&quot; name=&quot;buttonset&quot; value=&quot;button1&quot; <?php if($buttonset eq &quot;button1&quot;){print &quot;checked&quot;;}?>>
<br>
Button 2:<input type=&quot;radio&quot; name=&quot;buttonset&quot; value=&quot;button2&quot; <?php if($buttonset eq &quot;button2&quot;){print &quot;checked&quot;;}?>>
Something like this (I'm still new to PHP) ?
 
Great idea Gerry. I tried it and it worked great.

Thanks for the help.

:)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top