Intervelopment Posted November 2, 2010 Share Posted November 2, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/217541-dynamic-radiobutton/ Share on other sites More sharing options...
trq Posted November 2, 2010 Share Posted November 2, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/217541-dynamic-radiobutton/#findComment-1129393 Share on other sites More sharing options...
AbraCadaver Posted November 2, 2010 Share Posted November 2, 2010 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 Quote Link to comment https://forums.phpfreaks.com/topic/217541-dynamic-radiobutton/#findComment-1129495 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.