Forum Moderators: open

Message Too Old, No Replies

Adding a Add to guestlsit feature

Making a correlation between two tables

         

scraptoft

2:14 pm on Nov 1, 2007 (gmt 0)

10+ Year Member



I want to allow users to add themselfs to the going list of multiple events.

However I am unsure how to handle this in mysql. I presume I would need to make a field in either table_users or table_events.

e.g. create a field in table_users and store all the id's of the users going to this event. I could then do:

SELECT name from table_users where attendingevent_id='1'

My other problem then is how to store multiple id's in mysql?

I am very confused here so any help to spark my brain would be appreciated.

roldar

11:54 pm on Nov 1, 2007 (gmt 0)

10+ Year Member



You should normalize things a bit. Instead of adding a field to your event records, you should add a whole other table just to identify who is subscribed to which event. In this Subscriptions table you will need a Subscription_ID (primary key), User_ID, and Event_ID. The Subscription_ID is just an auto-incrementing integer, the User_ID is the primary key from the user table you already have, and the Event_ID is the primary key of the event from the event table.

This gets you around the problem of hacking some way to store multiple user IDs into a single record of one of your existing tables.