Jump to content

Archived

This topic is now archived and is closed to further replies.

ScorpionX

from DB to Form to update a record

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
[!--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 ^^

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.