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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.