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
https://forums.phpfreaks.com/topic/217541-dynamic-radiobutton/
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
https://forums.phpfreaks.com/topic/217541-dynamic-radiobutton/#findComment-1129495
Share on other sites

Archived

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

×
×
  • 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.