i'have problem when using simple html dom
my question is..
i want grabbing content from other website
but when i'm insert to db he is duplicate data or content
and how there was not duplicate data or entry
this for my code
include "simple_html_dom.php";
$html = new simple_html_dom();
$html = file_get_html('http://example/');
$items = $html->find('div[class=thumb-box latest-entries],div[class=thumb-box latest-entries no-margin]');
$nomor=1;
// loop into each li element
//echo"<h1>class margin</h1>";
foreach($items as $i => $post) {
// get the img
$img = $post->find('img', 0)->src;
// get the post's url
$url = $post->find('a', 0)->href;
// get the title
$title = $post->find('h2[class=article-heading]a', 1)->plaintext;
// another way to get the title
// $title2 = $post->find('div[article-text]', 0)->plaintext;
// get the description
$desc = $post->find('p[class=article-text]', 0)->plaintext;
//get date
$date = $post->find('span[class=date]', 0)->plaintext;
//get comment
$comment = $post->find('span[class=comment]', 0)->plaintext;
//get view
$view = $post->find('span[class=view]', 0)->plaintext;
// Print all
if($title != "" && $url !="" && $img !="" && $desc !="" && $date !="" && $comment !="" && $view !="")
{
echo "<h1>$nomor</h1>
Title :$title<br>
Image :$img<br>
Url :$url<br>
Description :$desc<br>
Date :$date<br>
Comment :$comment<br>
View :$view<br>";
$gambar =$img;
$link =$url;
echo "<hr/>";
}
$nomor++;
$display=mysql_query("select * from homepage where title='$title' && url='$url' && image='$img'");
if(mysql_num_rows($display)>0)
{
echo"<b style='color:red;'>title and url has Registered in database</b>";
}
else
{
mysql_query("INSERT INTO homepage (title,image,url,description,date,comment,view)values('$title','$gambar','$link','$desc','$date','$comment','$view')")or die("".mysql_error());
}
}