⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 search.php

📁 php源码 php源码参考
💻 PHP
字号:
<?php  include_once('db_fns.php');  include_once('header.php');  $handle = db_connect();  if ($_REQUEST['keyword'])   {    $keywords = split(' ', $_REQUEST['keyword']);    $num_keywords = count($keywords);    for ($i=0; $i<$num_keywords; $i++)     {      if ($i)      {        $keywords_string .= "or k.keyword = '".$keywords[$i]."' ";      }      else      {        $keywords_string .= "k.keyword = '".$keywords[$i]."' ";      }    }        $query = "select s.id,                     s.headline,                     10 * sum(k.weight) / $num_keywords as score              from stories s, keywords k              where s.id = k.story                    and ($keywords_string)                    and published is not null              group by s.id, s.headline              order by score desc, s.id desc";    $result = $handle->query($query);  }  echo '<h2>Search results</h2>';  if ($result  && $result->num_rows)   {    echo '<table>';    while ($matches = $result->fetch_assoc())     {      echo "<tr><td><a href='page?story={$matches['id']}'>             {$matches['headline']}             </td><td>";      echo floor($matches['score']).'%';      echo '</td></tr>';    }    echo '</table>';  }  else   {    echo 'No matching stories found';  }  include_once('footer.php');?>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -