I've been working with this problem for a few weeks now, and still haven't had any luck figuring it out on my own...
I am building an employee directory, the index page shows all employees names, their title, department, etc. Their name is a hyperlink, and when you click on it, you are taken to a screen with details of that employee along with their picture.
I have 2 tables:
emps: emp_id, emp_name, dep_id, (etc.)
deps: dep_id, dep_name
I basically need for emps.dep_id to match up with deps.dep_id and actually print out the corresponding dep_name.
I have it working correctly on the index page using the following code:
SELECT * FROM emps INNER JOIN deps ON emps.dep_id=deps.dep_id ORDER BY emp_name ASC
I have the details page working so that it pulls up the correct employee's information, but I cannot get it to print out the dep_name - everything I try only prints the dep_id.
This is what I currently have in the code on the details page:
SELECT * FROM emps INNER JOIN deps ON deps.dep_id = emps.dep_id AND emp_id=%s
Can anyone help me figure this out? I've tried everything that I can think of at this point... Thanks in advance!