Add a category table, so that you can keep track of them. Then, add a color_category table so you can have a many-to-many. Like so:
CategoryID Category
----------------------
1 primary
2 dark
ColorID CategoryID
---------------------
1 1
1 2
2 2
ColorID Color
-----------------
1 red
2 brown
Next, have a UserPalette table that looks like this:
UserID ColorID
-----------------
1 3
1 4
So, when a user selects dark
, you would run this query:
insert into userpalette
select
$userId as userid,
c.colorid
from
category cat
inner join color_category cc on
cat.categoryid = cc.categoryid
inner join colors c on
cat.colorid = c.colorid
where
cat.category = '$category'
To grab a user's colors, you'd do this:
select
c.color
from
userpalette up
inner join colors c on
up.colorid = c.colorid
where
up.userid = $userid
If you just have a username:
select
*
from
users u
inner join userpalette up on
u.userid = up.userid
inner join colors c on
up.colorid = c.colorid
where
u.username = '$username'
Obviously, make sure you pipe everything through mysql_real_escape_string()
before you put it into a SQL query. Otherwise, you're leaving yourself open for SQL injection attacks.