ScorpionX Posted May 4, 2006 Share Posted May 4, 2006 hi people,i got this DB and form.the form is used to insert data in the database,but now i want with the same kinda form to update the records.so i need to extract the data from the DB and insert them into the form.with a few textboxes this is no problem example:[code]<input type="text" name="input1-7" value="<?PHP printf("mysql_result($result,0,"Lastname")) ?>"/>[/code]but when i got a group of radiobuttons i know how to get them checked(in html), like this:[code]<input type="radio" name="RadioGroup1" value="1" /> <input type="radio" checked="checked"name="RadioGroup1" value="2" /> [/code]but i have no idea how to do this when i got a value like "2" how do i get the right one checked?i know it should be possible if u do somethin like this(just an example, wont work exactly like this)[code]<input type="radio" <?PHP IF ("mysql_result($result,0,"value")) = = "2"{print "checked=checked" ?> name="RadioGroup1" value="2" />[/code]but this would be 2 much work, cause i have a lot of radiobuttons...is there anyone who could help me with this problem?thnx for your time!greetz Scorp. Quote Link to comment Share on other sites More sharing options...
ober Posted May 4, 2006 Share Posted May 4, 2006 You need to create a loop that will build the radio button groups for you. The name of the group stays the same, and as long as the values are fairly uniform, you can put an if statement inside the for loop to check to see if the database value is equal to the loop value and if it is, echo the checked part, otherwise don't. Quote Link to comment Share on other sites More sharing options...
ScorpionX Posted May 4, 2006 Author Share Posted May 4, 2006 [!--quoteo(post=371239:date=May 4 2006, 03:11 PM:name=ober)--][div class=\'quotetop\']QUOTE(ober @ May 4 2006, 03:11 PM) [snapback]371239[/snapback][/div][div class=\'quotemain\'][!--quotec--]You need to create a loop that will build the radio button groups for you. The name of the group stays the same, and as long as the values are fairly uniform, you can put an if statement inside the for loop to check to see if the database value is equal to the loop value and if it is, echo the checked part, otherwise don't.[/quote]ok,thnx i will try that ^^ Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.