Linking Tables using PHP

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
nishmgopal
Forum Contributor
Posts: 101
Joined: Tue Mar 03, 2009 9:38 am

Linking Tables using PHP

Post by nishmgopal »

Hi Guys

I am researchin on the internet about how to define relationships between tables using php?

Basically I have say:

Job Table:

ID Name
---------
1 Manager
2 Developer
3 Analyst

Skill Table:

ID Name
----------
1 Java
2 C
3 C#

And I want to create the following table:

Job ID Skill ID
-------------
1 2
1 3
1 1
2 1
2 2

So by referencing the ID, I want to display the corresponding names so according to table above, the jod id 1 refers to manager and to do this job you need Java, C and C#.

Is this possible?

Thank you.
User avatar
jayshields
DevNet Resident
Posts: 1912
Joined: Mon Aug 22, 2005 12:11 pm
Location: Leeds/Manchester, England

Re: Linking Tables using PHP

Post by jayshields »

You need to use joins, or you could get away with doing it with a simple SELECT query.

Search around for many-to-many relationships and SQL, it's nothing to do with PHP.
Post Reply