I'm having trouble trying to get a nested < ul > inside of a while loop. I'm not sure if this even possible so i'm open to alternatives.
Here's a quick image of what my database looks like and what i'm trying to achieve.
Here's my sql
SELECT *
FROM drinks_category, drinks_lookup, drinks
WHERE drinks.drink_id = drinks_lookup.drink_id
AND drinks_lookup.drinks_category_id = drinks_category.drinks_category_id
ORDER BY drinks_category.drinks_category_title
Here's my output php
$result = $conn->query($sql) or die(mysqli_error());
$last_category = 0;
while ($row = $result->fetch_assoc()) {
if($row['drinks_category_id'] != $last_category) {
echo "<h1>" . $row['drinks_category_title'] . "</h1>";
}
echo "<p>" . $row['drink_name'] . "</p>";
$last_category = $row['drinks_category_id'];
}
Im using mysqli and php. Thanks in advance!