Possible Duplicate:
How to delete duplicate rows from a MySQL table
I have been looking all across the Internet for a decent answer but I still don't understand how to delete duplicate rows. I have a query below and can someone please show me how to correctly implement the ability to delete duplicate rows?
Any ideas?
$bbc_values = array('http://www.bbc.co.uk/news/health-',
'http://www.bbc.co.uk/news/politics-',
'http://www.bbc.co.uk/news/uk-',
'http://www.bbc.co.uk/news/technology-',
'http://www.bbc.co.uk/news/world-',
'http://www.bbc.co.uk/news/england-',
'http://www.bbc.co.uk/news/northern_ireland-',
'http://www.bbc.co.uk/news/scotland-',
'http://www.bbc.co.uk/news/wales-',
'http://www.bbc.co.uk/news/business-',
'http://www.bbc.co.uk/news/education-',
'http://www.bbc.co.uk/news/science_and_enviroment-',
'http://www.bbc.co.uk/news/entertainment_and_arts-');
// BBC Algorithm
foreach ($links as $link) {
$output = array(
"title" => Titles($link), //dont know what Titles is, variable or string?
"description" => getMetas($link),
"keywords" => getKeywords($link),
"link" => $link
);
if (empty($output["description"])) {
$output["description"] = getWord($link);
}
$data = '"' . implode('" , "', $output) . '"';
if (substr_in_array($output, $bbc_values)) {
$result = mysql_query("INSERT INTO news_story (`title`, `description`, `keywords`, `link`) VALUES (" . $data . ")");
$delete = mysql_query("DELETE FROM news_story WHERE link='{$output['link']}'");
}
if (!substr_in_array($output, $bbc_values)) {
echo "Does not equal data";
}