做了一个mysql表格,有好几百条记录,相当于通讯录,表格的字段为,公司名称,网址,电话,地址.
现在我想用php循环删除网址不能访问的记录.想知道php程序怎么写
13723868561 发表于2017-03-05 20:35
有些网址是不能访问 的
<?php
require '../../../../../public_file/database_connection.php';
$sql=mysql_query("select url from corp");
$row=mysql_fetch_row($sql);
$check = @fopen($row,"r");
$id=
do{
if(!$check)
{
$rst = mysql_query("delete from corp where id=$id");
}
}while($row=mysql_fetch_row($sql));
if(!$rst){echo "删除失败!<a href='insert1.php'>返回</a>";die;}
echo "删除成功!<a href='insert1.php'>返回</a>";
?>
帮忙看下要改哪里
如果是规范的url,试下如下修改之后代码:
<?php
require '../../../../../public_file/database_connection.php';
$sql=mysql_query("select url from corp");
do{
$check = @fopen($row['url'],"r");
if(!$check)
$rst = mysql_query("delete from corp where id=$row['id']");
}while($row=mysql_fetch_row($sql));
?>