Jump to content

[SOLVED] Storing mult-select form data in mysql


coolbeansdude51

Recommended Posts

Hello all.

 

Here is the problem.  I have an application with users.  I need to put those people into groups.  Right now I have a separate table full of the groups.  I query the groups table to place all the data in the form.  Then I need to place data in table called members which has all the members data in it.  Right now I have 1 field holding all the group data.  I serialize the group array and then unserialize it when I need to pull it out.  It works but I there has to be an easier way or a more correct way.

 

I am running into problems when I need to build an msyql query to find members based on which groups they are in and then execute a script based on the members group association.

 

Here are some thoughts:

Would it just make more sense to create a field in the members table for each group?  That would be a pain because the number of groups is constantly changing ...

 

Pull in all the members into an array ... and the members groups then search through it building another array full of the members that meet the criteria ...

 

Hopefully that makes sense.  Let me know!

 

Any idea's?

It seems like you don't know too much about normalization.

If I understand your matter, you'd better create a "users-groups" table in which you'll store a record for each user of each group

 

You are right ... I don't know much about normalization at all.  Thanks for the idea! To make sure I understand you correctly.

 

It would look something like this:

 

record1 = member1 group1

record2 = member1 group2

record3 = member2 group1

 

Something to that effect ... Correct?

 

Thanks for your reply and time.  I really appreciate it.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.