On 6/29/09 10:26 PM, "Michael A. Peters" <mpeters@xxxxxxx> wrote: > Rob Gould wrote: >> I have a webpage which allows people to log in and make selections with >> radio buttons and hit SUBMIT and saves the data from those radio buttons >> to a mySQL database. >> >> However, I'm finding that I also need the ability to allow a user to log >> back in at a later date (or even on a different computer), and pull up >> that survey again, >> with each of the 50-something radio-buttons back in the positions in >> which they were last saved. >> >> Surely there's a best-case-method for doing this type of thing (saving >> large numbers of radio-button-group settings to mySQL and pulling them back >> again later). Any advice is greatly appreciated. Perhaps there's a >> jQuery-way to retrieve all the radio-button group settings as an array >> and save it and pull it back again? >> Or perhaps a PHP-specific method - - - I'm fine with either. >> > > Generate your radio list via php. > When the value grabbed from database matches the button value, add a > selected="selected" to the radio input. > > Works for me. michael: radios and checkboxes take the checked attribute -- options in selects take the selected attribute. http://www.w3.org/TR/html401/interact/forms.html#checkbox rob: if you use systematic naming of the radio input elements (e.g. a common prefix) then you can use a simple loop to generate an SQL query from the $_POST array to store the form state as a string. then use another loop to generate the markup for all your radios, inserting the checked attribute for those radios whose names appear in the string you stored in the DB. the key is the systematic naming and having a page design (and maybe template scheme, if you like) that allows simple automated generation of the form's markup. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php