$keyword = trim($_REQUEST['keyword']); if (!empty($keyword)) { $str = ""; $count = ""; /* 搜索表名称 */ $arr = array("index_YQDT" => '`title`,`content`', "index_CYZC" => '`title`,`content`', "index_CYTD" => '`title`,`content`', "index_TZGG" => '`title`,`content`', "index_ZYXZ" => '`title`', "YS_about" => '`title`,`content`', "YS_build" => '`title`,`content`', "CY_news" => '`title`,`content`', "CY_teamnews" => '`title`,`content`', "CY_job" => '`title`'); foreach ($arr as $key => $value) { $row = explode(",", $value); $title = str_replace("`", "", $row[0]); $content = str_replace("`", "", $row[1]); $sql = "SELECT * FROM " . $key . " "; for ($i = 0; $i < count($row); $i++) { $sql .= (preg_match('/WHERE/i', $sql) ? ' or ' : ' WHERE ') . $row[$i] . " like '%" . $keyword . "%' "; } $pdo = new PdoMySQL(); $pdo->query($sql); while ($site = PdoMySQL::$PDOStatement->fetch(constant("PDO::FETCH_ASSOC"))) { $title2 = str_ireplace($keyword, "<strong><font color='red'>" . $keyword . "</font></strong>", $site[$title]); $content2 = str_ireplace($keyword, "<font color='red'>" . $keyword . "</font>", cut_str_with_string(strip_tags($site[$content]), 180)); switch ($key) { case 'index_YQDT': $href = "index_YQDT.php?id=" . $site['id']; break; case 'index_CYZC': $href = "index_CYZC.php?id=" . $site['id']; break; case 'index_CYTD': $href = "index_CYTD.php?id=" . $site['id']; break; case 'index_TZGG': $href = "index_TZGG.php?id=" . $site['id'];