Many-to-Many problems

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
MiniMonty
Forum Contributor
Posts: 196
Joined: Thu Sep 03, 2009 9:09 am
Location: UK

Many-to-Many problems

Post by MiniMonty »

Hi all,

trying to set up a students / courses system and hoping someone can help
because I'm a bit out of my depth. All and any help on this much appreciated.
I took this project on for a friend when it looked simple
and it's now getting beyond my skill set as a Front end designer !

So I have a table "myMembers" which has the member basics; name, id (a number), email, password etc.
I have a table "courses" which has course_ID, course_name and course_tutor.
I think this looks like a many-to-many scenario which is something I've never tackled and after
research I'm honestly more confused than when I started :(

There are six courses that members can sign up for.
I'm confused as to where to record which member has signed up to which course
and then how to query the "join" table (members_courses) to return, for instance, which courses
any particular member has signed up for, or which list of members has signed up to any particular course.

Very grateful for any help

Best wishes
Monty
User avatar
Grizzzzzzzzzz
Forum Contributor
Posts: 125
Joined: Wed Sep 02, 2009 8:51 am

Re: Many-to-Many problems

Post by Grizzzzzzzzzz »

.. not entirely sure what you want help with, but i assume you're stuck on how to resolve the many-many relationship issue...which isn't really a PHP issue.. but whatever!

in this case i believe you'd create a link table between the two tables with two fields in it (member ID + Course ID) that become a compound key.

something similar to this

Image

http://articles.techrepublic.com.com/51 ... 34790.html
Post Reply