在MYSQL中按字母顺序排序具有多个单词和顺序的行

I am so close but need some help please. On my site I have tag words (visit here) -- As you can see I have 2 words named America then it says Persecution then Christians. Here is where I need help.

  1. I need only one word for America not two words.
  2. In the first row on my website (please go there to view) it says Abortion America America Persecution Christians then Animals... As you can see this is not in alphabetical order. I need for this to be in alphabetical order with the rest of the words.

Right now I am testing one row with three words inside and all the rest only have one word inside. The test row has the words America, Persecution, Christians. Until I learn how to achieve what I need then all the rows will have more than one word inside.

enter image description here

Here is my code below ----

<?php
          include('connect.php');
          //now execut Select statement on table
$sql = mysqli_query($db_xxx, "SELECT word FROM articles GROUP BY word ORDER BY word ASC");

while ($row = mysqli_fetch_array($sql)) { 
$link = $row['link'];
$word_array = explode(", ", $row['word']); $unique_word_array = array_unique($word_array); 

foreach($unique_word_array as $key) 
{ 
        echo "<div class='cloudbox tag'><a href = '../../articlestagresults.php?word=" . $key . "'> " . $key . "</a></div>"; }

}

   // Close your database connection
mysqli_close($db_xxx);
?>

Again I need help to combine the words America and put all those tag words in alphabetical order, thank you. If you need further information please ask. I really need help on this, again thank you.

I used asort() on $unique_array_word variable, the following is your code with the added sort function call:

$sql = mysqli_query($db_xxx, "SELECT word, word2 FROM post");  
while ($row = mysqli_fetch_array($sql)) { $link = $row['link']; 
  $word_array = explode(", ", $row['word']);
  $unique_word_array = array_unique($word_array);
  asort(unique_word_array);
  foreach($unique_word_array as $key) {
    echo "<div class='cloudbox tag'><a href = '../../articlestagresults.php?word=" . $key . "'> " . $key . "</a></div>"; 
  }
}

I hope this would help u achieving what you want.