Skip to content
Advertisement

how to repeat rows only once in many to many relationship

I’m working on many to many relationship on php I have 3 tables , movie table which contains movie name and movie id genre table which contains genre and genre id and movie_genre table which has movie id and genre id
genre table has these values

JavaScript

I used the code below to fetch the data

JavaScript

but the result would be like
movie_id movie_name genre[1]
movie_id movie_name genre[2]
movie_id movie_name genre[3]
an example

JavaScript

the result I want is

JavaScript

I did try using limit 1 but the result was showing only the first genre

Advertisement

Answer

Will need to do a loop just for the genres I can’t test this, so this is throwing together just what I imagine will work, but it will be something along these lines, there might be errors in syntax here

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement