foreach($sites as $url)
{
print_r($url);
$db = mysql_connect("localhost","root","11") or die("\nerror connecting". mysql_error());
mysql_select_db("website_categorization") or die("\n error selecting database" );
mysql_real_escape_string($url);
mysql_query("INSERT INTO url_main(Url) VALUES('$url')") or trigger_error(mysql_error());
$result = mysql_query("SELECT ID from url_main where url='$url'");
list($url_id) = mysql_fetch_row($result);
$keyword = get_meta_tags("http://".$url);
if(array_key_exists('keywords', $keyword))
$tag = $keyword['keywords'];
elseif(array_key_exists('Keywords', $keyword))
$tag = $keyword['Keywords'];
else
{ mysql_query("INSERT INTO uncategorized(Url) VALUES('$url')") or trigger_error(mysql_error());
break;
}
}
即使程序的控制权达到else语句,我仍希望继续运行程序。即使遇到其他结构,你能帮助我做我必须做的事情让我的程序运行其他$ url值....
这是代码的其余部分。
$keyword_array = preg_split('/[\s,]+/ ', $tag);
foreach( $keyword_array as $url_keyword )
{
mysql_real_escape_string($url_keyword);
$query = "SELECT ID from category_keyword where Keyword='$url_keyword'";
$result = mysql_query($query);
while($row=mysql_fetch_array($result))
{
$out = mysql_query("INSERT INTO url_keyword(Url_ID,Keyword,Keyword_ID) values ($url_id, '$url_keyword','$row[ID]')");
}
$query2 = "SELECT ID_Category, sum(Score) as score from `category_keyword` as ck ,`url_keyword` as uk where ck.ID = uk.Keyword_ID and Url_ID=$url_id group by ID_Category";
$result2 = mysql_query($query2);
}
while($row2 = mysql_fetch_array($result2))
{
print_r($row2);
if( $row2['score'] > $THRES )
{
$query3="INSERT INTO url_category_map(Url_ID, Category_ID) values( $url_id, $row2[ID_Category])";
$out3 = mysql_query($query3);
$FLAG=true;
}
}
}
答案 0 :(得分:1)
完全删除break
。