MySQL many to many relation
You are doing the right way,

In many-to-many relation your must have a third table mapped by the ID of the two other tables. The two Id must be foreign key, and the association of the two is the primary key of your association's table

You can also store in this table the information that are related on the relation.