I have two tables. One is called "employee" and has a column named "role". I have another table with the name "role" that has two columns in it "role_id" and "name".
I have linked the two in MySQL with a foreign key (I think!), by going to relationship view through phpmyadmin and selecting the appropriate settings.
Now in PHP I have the following code:
$employees = "SELECT employee_id, first_name, last_name, role
FROM employee
WHERE status = 1";
$employee = mysqli_query($link, $employees);
foreach ($employee as $employeeInfo) {
<?php echo $employeeInfo['role'];?>
}
However, this returns the number I have assigned to the role in the employee's table. Not the name from the linked table.
I think it has something to do with having to use the JOIN condition is the PHP code. However, doing some experimentation just gets me blank results.
Do you have any tips for outputting the role name from the second table in this case?
Thank you