Good practice to store user settings PHP/MySQL

I am currently building (a 1001th) community website. I already build the whole interface with hundreds of lines of CSS. Also the relational MySQL database is also build ready in MySQL Workbench.

I set up a fully working multi-language and ActiveRecord CodeIgniter workspace so I'm read-set to go.

I have one last thing I'm pondering about. The user's preferences storing methodic.

I had something like this in the DB structure:

user_preferences
" pref (VARCHAR(45))
" value (TEXT)

I know the methods to store arrays in the a DB-field etc. but I was wondering how others do it. I want to do it DB-wise.

Now I can achieve things like:
$query = mysql_query("SELECT * FROM user_preferences WHERE users_id == $_SESSION['user_id']");

$result = mysql_fetch_assoc($query);

// Some loop through these 2 values to combine them in a logic result
// After collecting all data storing them in a ordered array or object and store it in the SESSION or something like that
$result[0]['pref'];
$result[0]['value'];

Open in new window

LVL 3
Erwin_001Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

asafadisCommented:
Looks fine to me.
I would even dare to say that this is the "industry standard"!

It's the same technique WordPress uses: http://codex.wordpress.org/images/8/83/WP_27_dbsERD.png
Check out the "usermeta" table on the top left.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Erwin_001Author Commented:
Nice : ).

I'm having community settings like:

show_dateofbirth (yes, no, friends_only)
show_age
show_profile

etc.

Guess this is satisfactory enough. I works pretty well until now : ). Was just wondering.

Thanks
Erwin_001Author Commented:
-
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.