Forum Moderators: coopster

Message Too Old, No Replies

Checkboxes......

         

g0dfaTHer

5:51 pm on Jan 4, 2004 (gmt 0)

10+ Year Member



Need some help with the code. I have a form that collects info from a user. The first part of the form collects username, name, etc, etc, etc, etc. I have no problem here getting this info to go to the DB and than to another page and be displayed. Than at the bottom of my form i have a question about games. than underneath it are check boxes for the games listing out about 10 games. One game can be checked, 5 can be checked, 10 can be checked...I have created a table in my database called games_played.

in the table there is:

id games.

I have tried many different codes but cant seem to find something that works. ANyone have any ideas? I am farely new to PHP and was able to pick up the first part of my form with no problem.

Thanks

dmorison

5:58 pm on Jan 4, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



A neat trick for storing user preferences in a database is to use PHP's serialize() [uk2.php.net] function.

Within your PHP application, maintain an array called $options, with elements corresponding to the users' settings; or in your case the games they have selected.

Then, in your database, have a single field called "options".

When the user has set options; write the output of serialize($options) into the options field in your DB. On retrieving a user record; use unserialize() [uk2.php.net] to recover the array from the DB.

This saves having hundreds of separate option field in your user table, and has the side benefit of reducing DB size considerably if you only populate values once they are set to TRUE.

For retrieving option values from a FORM, refer to this page on the PHP website:

[uk2.php.net...]

g0dfaTHer

7:59 pm on Jan 4, 2004 (gmt 0)

10+ Year Member



Thank you Ill give this a whirl.... Thanks again!