Jump to content

PHP: Comparing data from two MySQL tables


Recommended Posts

i want to modify a php/mysql database for the small college I work for

Its a database containing student infomation and what courses they are doing. The problem is, it only contains the course codes - not the actual names of the courses. Members of staff have to look up the code to see what course it is.

I dont wish to edit every student becasue there's far to many.

I tried the following PHP code which displays the word "hairdressing" if it finds course code 100410IC001:

if ( $course_id == "100410IC001" ) {
echo "hairdressing";
}
else echo "course name not found";

some students are doing more than one course. Although the above code works if the student is doing one course, if they are doing multiple course, it displays the word "hairdressing for each course (even though they have different ID codes.

doing it this way isn't very good anyway. I want to make use of MySQL so people can add more courses using a form. I added a new table to the MySQL database containg courses and theirs codes. I want it to look up the course id in my new table and display its course name. Ive been having problems doing this.

Please can anybody give some advise on the best way to do this?

Many thanks

At0mic

Link to comment
Share on other sites


give us an idea as to what the different course coses are, and also are all the students referenced by course?

By the way as a matter of intrest is th eindex the student name or what is it?

need to know to try and make the cod distinguish between courses and students.

Edited by phkninja
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...