I have to make a website that will display info about "hotels" from a database. I have 2 tables: 'locations' and 'ratings'. The problem: If I have more than 1 rating, the entire loop with same locationID get's printed twice with the 2 different comments. Should I use something else than LEFT JOIN for this?
CURRENT OUTPUT: Current
PLANNED OUTPUT: Planned
$sql = "SELECT * FROM locations LEFT JOIN ratings ON ratings.locationID=locations.locationID WHERE locationKind = 'hotel'";
$result = $conn->query($sql);
while ($row = $result->fetch_assoc()) {
$image = $row["image"];
$locationName = $row["locationName"];
$description = $row["description"];
$link = $row["link"];
$comment = $row["comment"];
echo "<tr>";
echo "
<td><img style='width:100%;height:100%;border-radius:8px;' src='images/$image'/></td>";
echo "<td style='padding: 0 30px;'><a class='locationName'>$locationName</a><br/><br/>$description</br></br><div class='bookNowButton'><a href='$link' class='bookNowButtonText'>BOOK NOW!</a><div></td>";
echo "<td>
<br>/<br>
<a>Booking.no</a></td>";
echo "</tr>";
}
echo "</table>";
?>