I've been trying to do this all day with no result and would be grateful for a push in the right direction.
So I have a cooking website with a table similar to this
id recipe ingredients
1 Apple pie Apples, eggs, flour
2 Peach pie Peaches, butter, flour
3 Cherry pie Cherries, flour, eggs, butter
I would like to pull all the data from the Ingredients field, get rid of the duplicates, sort them alphabetically and echo a list like this:
Apples
Butter
Cherries
Eggs
Flour
Peaches
I've tried
<?php
$result = mysqli_query($dbconnect, "SELECT ingredients FROM recipes");
$result1 = join(",",$result);
$result2 = array_unique($result1);
foreach ($result2 as &$value)
{
echo "<li>$value</li>";
}
Which does not work.
Would really appreciate any suggestions.
Thanks!