Problem with SELECT JOIN when trying to print out a name once
I have a problem when I'm attempting to print out a specific director name for specific movie. I can print out info such as "title" and "production year" for a specific movie, which is stored in a db-table called "filmer", with this code.
But I also want to be able to print out the specific director in text for the specific movie, and to print out the director name in text (while connecting it to the actual movie) I have to join the db-table "regissorer", which stores the director names in strings. But when I use the following code I cannot make the director name print out only ONCE, it just prints out all of the director names stored in the regissorer-table. The code:
$sql = "SELECT * FROM filmer where id = $id";
Does anyone know how to fix this?
$sql = "SELECT filmer.*, regissorer.fornamn, regissorer.efternamn
FROM filmer JOIN regissorer
ON regissorer.id = filmer.regissor_id WHERE id = $id";