Jump to content

from DB to Form to update a record


ScorpionX

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.