Jump to content

Perry Mason

Members
  • Posts

    35
  • Joined

  • Last visited

Contact Methods

  • Website URL
    http://www.medeponyms.com

Profile Information

  • Gender
    Not Telling

Perry Mason's Achievements

Member

Member (2/5)

0

Reputation

  1. Thanks. Unfortunately it didn't work. I've also tried $result= mysqli_query ($dbcnx, "SELECT key_ingredient FROM recipes"); $numrows = mysqli_num_rows($result); while ($result) { $row = mysqli_fetch_array($result); $joined = array_merge($row[0],$row[1],$row[2]); $word_array = preg_split('/[\s?:;,.]+/', $joined, -1, PREG_SPLIT_NO_EMPTY); $unique_word_array = array_unique($word_array); foreach ($unique_word_array as $word) { echo "<li>$word</li>"; } } Any ideas? There has to be a way to combine data from multiple rows into one array. I think I know what to do from that point.
  2. 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!
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.