I am using mySQL for my news tables.. some of the headlines field in my table contain the exact same content (but they are from a different source so I need to keep them in the table).
Unfortnately, I don’t want to display the articles with the same headlines.. so how do I remove rows from my query array that have the identical headlines?
[code]
$sql = “SELECT id, headline FROM newsTable WHERE headline LIKE ‘%$userChannel%’ OR body LIKE ‘%$userChannel%’ LIMIT 10”;
$result = mysql_query($sql);
while ($row = mysql_fetch_assoc($result)){
echo ‘<p><a href=”http://www.foo.com/thread.php?id=’.$row[id].'”>’.$row[headline].'</a></p>’;
}
I tried SELECT DISTINCT in mySQL but it doesn’t work.. so there must be a PHP solution to compare the headline field for each row and not display like headlines…
I then tried $row = array_unique($row); but it doesn’t work either.. I think I am using array_unique() incorrectly:
[code]
$sql = “SELECT id, headline FROM newsTable WHERE headline LIKE ‘%$userChannel%’ OR body LIKE ‘%$userChannel%’ LIMIT 10″;
$result = mysql_query($sql);
while ($row = mysql_fetch_assoc($result)){
$row = array_unique($row);
echo ‘<p><a href=”http://www.foo.com/thread.php?id=’.$row[id].'”>’.$row[headline].'</a></p>’;
}
I want to remove duplicate headline items from the array…
can anyone help me out please?