我的搜索算法导致挂起

时间:2017-03-10 13:11:56

标签: php search

我制作了一个搜索系统,用于比较搜索键的所有记录。当数据库记录增加挂起时,它可以处理100条记录,现在可以挂起600条记录。

看看它:

for ($i=0;$i<$rom_num;$i++)
{
    $score = 0;
    $title = "رام ".mysql_result(mysql_query("SELECT romk FROM $prefix"."roms ORDER BY time"),$i,0)." ".mysql_result(mysql_query("SELECT comp FROM $prefix"."roms ORDER BY time"),$i,0)." ".mysql_result(mysql_query("SELECT family FROM $prefix"."roms ORDER BY time"),$i,0)." ".mysql_result(mysql_query("SELECT model FROM $prefix"."roms ORDER BY time"),$i,0)." ".mysql_result(mysql_query("SELECT modnum FROM $prefix"."roms ORDER BY time"),$i,0)." ".mysql_result(mysql_query("SELECT androidv FROM $prefix"."roms ORDER BY time"),$i,0)." ".mysql_result(mysql_query("SELECT buildnum FROM $prefix"."roms ORDER BY time"),$i,0)." ".mysql_result(mysql_query("SELECT region FROM $prefix"."roms ORDER BY time"),$i,0);
    $name = "رام ".mysql_result(mysql_query("SELECT romk FROM $prefix"."roms ORDER BY time"),$i,0)." اندروید ".substr(mysql_result(mysql_query("SELECT androidv FROM $prefix"."roms ORDER BY time"),$i,0), 0,1)." برای ".mysql_result(mysql_query("SELECT comp FROM $prefix"."roms ORDER BY time"),$i,0)." ".mysql_result(mysql_query("SELECT model FROM $prefix"."roms ORDER BY time"),$i,0);
    $ser = mysql_result(mysql_query("SELECT ser FROM $prefix"."roms ORDER BY time"),$i,0);
    $title = explode(" ",$title);
    foreach($title as $word)
    {
        $word = strtolower(str_replace("!","",$word));
        $word = str_replace("?","",$word);
        $word = str_replace("؟","",$word);
        $word = str_replace(".","",$word);
        $word = str_replace(",","",$word);
        $word = str_replace(":","",$word);
        $word = str_replace("&prime;","",$word);
        $word = str_replace("&quot;","",$word);
        $er = 1;

        foreach($keywords as $keyword)
        {
            if ($word == $keyword)
            {
                $er = 0;
            }
        }
        if ($er == 0) {
            $founded = 1;
            $score = $score + 1000;
            if ($cfm[$ser] == '') {
                $cfm[$ser] = str_replace($word,"<span class='highlight'>$word</span>",$name);
            }
            else
            {
                $cfm[$ser] = str_replace($word,"<span class='highlight'>$word</span>",$cfm[$ser]);
            }
        }
        else
        {
            $score = $score - 1;
        }
    }

    $results['rom:'.$ser] = $score;
    if ($score > 0) {$results_num++;}
}

0 个答案:

没有答案