Php mysql中的简单html dom复制项

Php mysql中的简单html dom复制项,php,html,mysql,database,dom,Php,Html,Mysql,Database,Dom,我在使用简单的HTMLDOM时遇到问题 我的问题是 我想从其他网站抓取内容 但当我插入数据库时,它是重复的数据或内容 以及如何没有重复的数据或条目 这是我的密码 包括“simple\u html\u dom.php”; $html=新的简单html\U dom(); $html=file\u get\u html('http://example/'); $items=$html->find('div[class=thumb-box-latest-entries],div[class=thumb-

我在使用简单的HTMLDOM时遇到问题

我的问题是

我想从其他网站抓取内容

但当我插入数据库时,它是重复的数据或内容

以及如何没有重复的数据或条目

这是我的密码

包括“simple\u html\u dom.php”;
$html=新的简单html\U dom();
$html=file\u get\u html('http://example/');
$items=$html->find('div[class=thumb-box-latest-entries],div[class=thumb-box-latest-entries-no-margin]);
$nomor=1;
//循环到每个li元素中
//呼应“阶级界限”;
foreach($i=>$post形式的项目){
//获取img
$img=$post->find('img',0)->src;
//获取帖子的url
$url=$post->find('a',0)->href;
//得名
$title=$post->find('h2[class=文章标题]a',1)->纯文本;
//另一种获得头衔的方式
//$title2=$post->find('div[article text]',0)->纯文本;
//得到描述
$desc=$post->find('p[class=文章文本]),0)->纯文本;
//约会
$date=$post->find('span[class=date]',0)->纯文本;
//获得评论
$comment=$post->find('span[class=comment]',0)->纯文本;
//查看
$view=$post->find('span[class=view]',0)->纯文本;
//全部打印
如果($title!=“”&&$url!=“”&&&$img!=“”&&&$desc!=“”&&&$date!=“”&&&$comment!=“”&&&$view!=“”)
{
echo“$nomor
标题:$Title
图片:$img
Url:$Url
说明:$desc
日期:$Date
评论:$Comment
视图:$View
“; $gambar=$img; $link=$url; 回声“
”; } $nomor++; $display=mysql_query(“从主页中选择*,其中title='$title'&&url='$url'&&image='$img'); 如果(mysql_num_rows($display)>0) { echo“标题和url已在数据库中注册”; } 其他的 { mysql_查询(“插入到主页(标题、图像、url、描述、日期、注释、视图)值(“$title”、“$gambar”、“$link”、“$desc”、“$date”、“$comment”、“$view”)或死(“.mysql_error()); } }
您是否向phpmyadmin查询了内容?它可能已添加到数据库中,但您的$display查询可能无法正常工作,因此它将始终没有行=>正在尝试将新条目添加到数据库中,而这些条目已经添加。

还有,您的主键是什么?它是由多个atributes组成的吗?好的,谢谢besciualex,我已经在phpmyadmin登记了,是添加新的,第一步,我取得了成功,但是当我在唠叨第二步时,他将是我数据库中的重复条目。如果这对你有效,请接受答案。谢谢