I’m trying to do a many-many database select, where I have events and music styles (among others). However since one event can have multiple music styles I decided to do a many-many relationship model.
This is what I created:
SELECT
a.* FROM music_types AS a, events_music_types AS b
WHERE
a.id = b.music_type_id
AND
b.event_id = events.ID
And inserted it into my code which now looks like this:
$query =
"SELECT
events.EVENT_NAME, events.start_datetime, events.end_datetime, events.VENUE_LOCATION, events.PARTY_TYPE, events.IMAGE_URL, events.ENTRANCE_PRICE,
venues.VENUE_NAME, venues.BEER_PRICE, venues.WINE_PRICE, SPIRITS_PRICE,
party_types.PARTYTYPE,
a.*
FROM events
INNER JOIN venues
ON events.VENUE_LOCATION = venues.ID
INNER JOIN party_types
ON events.PARTY_TYPE = party_types.ID
INNER JOIN music_styles AS a, events_music_styles AS b
WHERE start_datetime >= '$DATE_START_SELECTED'
AND end_datetime < '$DATE_END_SELECTED'
AND a.id = b.music_style_id
AND b.event_id = events.ID
";
$result = mysql_query($query) or die(mysql_error());
echo "<table border='1'>
<tr>
<th> Poster </th>
<th> Event Name </th>
<th> Venue Name </th>
<th> Party Type </th>
<th> Entrance Price </th>
<th> Music </th>
<th> € of Beer </th>
<th> € of Wine </th>
<th> € of Spirits </th>
</tr>";
while($row = mysql_fetch_array($result, MYSQL_ASSOC)){
echo "<tr>";
echo "<td><IMG src='" . $row['IMAGE_URL'] . "'></td>";
echo "<td>" . $row['EVENT_NAME'] . "</td>";
echo "<td>" . $row['VENUE_NAME'] . "</td>";
echo "<td>" . $row['PARTYTYPE'] . "</td>";
echo "<td>" . $row['ENTRANCE_PRICE'] . "</td>";
echo "<td>" . $row['MUSIC_STYLE_NAME'] . "</td>";
echo "<td>" . $row['BEER_PRICE'] . "</td>";
echo "<td>" . $row['WINE_PRICE'] . "</td>";
echo "<td>" . $row['SPIRITS_PRICE'] . "</td>";
echo "</tr>";
}
However, while the code does get all of the music styles for an event, it doesn’t put it into one row but duplicates the row the amount of times that there are musical styles for each event.

How would I go about combining it into one row and separating the music styles with a comma? Thanks :)!
Change your query to –
You also had a mix of join styles before which I have now corrected.