• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1466
  • Last Modified:

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:

" 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

Open in new window

  • 2
1 Solution
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.
Erwin_001Author Commented:
Nice : ).

I'm having community settings like:

show_dateofbirth (yes, no, friends_only)


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

Erwin_001Author Commented:
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now