Jump to content

Dynamic RadioButton


Intervelopment

Recommended Posts

Hey All,

 

Im having trouble tring to figure out how to save dynamic radio buttons.

 

I have a project where i have to use radiobuttons instead of checkboxes.

 

Basically, there is a database table with "roles" in it ... i.e administrator, user, etc etc etc and these are updateable but the user.

 

On a specific page, these get spit out with a radio button next to them, like so:

 

<input name="wfa" type="radio" id="wfa" class="radio" value="1" /><label for="wfa">administrator</label> 

 

These go on down the page, for as many entries there are in the database.

 

What i need to do is save the checked ones to the database, but being dynamic i cant save each value to a individual row ..... any help?

 

Someone mentioned serialize, i had a look at the php documentation but it didnt make much sense to me.

 

Cheers.

Link to comment
Share on other sites

What i need to do is save the checked ones to the database, but being dynamic i cant save each value to a individual row

 

Why not? This makes it completely dynamic.

That's exactly what you should do.  Each row would have the userid and the role.  If the user has multiple roles then there will be multiple rows with the same userid and different roles.  This how you use relational databases.  In this way you can get all the user's roles with:

 

SELECT * FROM roles WHERE userid = 1

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.