1 Star 0 Fork 0

ica / bbs_0

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
search.php 3.09 KB
一键复制 编辑 原始数据 按行查看 历史
Moe-boshi 提交于 2018-06-27 17:04 . 180627
<?php
/**
* Created by PhpStorm.
* User: clkj1
* Date: 2018/6/21
* Time: 9:32
*/
require 'core/header.php';
//$得出的结果 = preg_replace($搜索的值, $替换成的值, $需要替换的值[,$替换几个,$替换了多少个,输出])
//$text = preg_replace($search_result, "<span style="color:#ff0000">".$content."</span>", $topicid_posts)
if (isset($_GET['tag'])){
if ($_GET['content']==""){
echo '<script>history.back();</script>';
exit();
}
if ($_GET['tag'] == 1){
$search_result = sql_search_topics(addslashes(trim($searchContent)));
echo '<hr />结果:找到"'.htmlspecialchars($searchContent).'"相关内容 '.$search_result[1].' 个<hr />';
while (($result_array = mysqli_fetch_array($search_result[0])) != null) {
//根据topicid找到主题内容
$topicid = $result_array['topic_id'];
$topicid_posts = sql_topicid_posts($topicid);
$set_search = "/".htmlspecialchars($searchContent)."/";
$change_search = "<span style=\"color:#ff0000\">" . htmlspecialchars($searchContent) . "</span>";
$get_title = $result_array['topic_title'];
$get_content = $topicid_posts['post_content'];
$set_title = preg_replace($set_search, $change_search, $get_title);
$set_content = preg_replace($set_search, $change_search, $get_content);
$echo_title = '<a href="topic.php?topicid='.$topicid.'&p=1">'.$set_title.'</a>';
$echo_content = $set_content;
echo $echo_title;
echo '<br />';
echo $echo_content;
echo '<br />';
//主题发表时间-作者-板块
$topic_createtime = $topicid_posts['post_createtime'];
echo date('Y-m-d',$topic_createtime);
$topic_auther = $topicid_posts['post_authuid'];
//根据id查用户名/home.php?mod=space&uid=1
$auther_all = sql_search_uid_all($topic_auther);
$auther_uid = $auther_all['user_uid'];
$auther_name = $auther_all['user_username'];
echo '&nbsp;<a href="home.php?mod=space&uid='.$auther_uid.'">'.$auther_name.'</a>';
//forumid/forums.php?forumid=14&p=1
$forums = sql_topicid_forums($topicid);
$forumid = $forums['forum_id'];
$forumname = $forums['forum_name'];
echo '&nbsp;<a href="forums.php?forumid='.$forumid.'&p=1">'.$forumname.'</a>';
echo '<hr />';
}
}elseif ($_GET['tag'] == 2){
$search_result = sql_list_users(addslashes(trim($searchContent)));
echo '<hr />结果:找到"'.htmlspecialchars($searchContent).'"相关用户 '.$search_result[1].' 个<hr />';
while (($result_array = mysqli_fetch_array($search_result[0])) != null) {
//根据topicid找到主题内容
$userid = $result_array['user_uid'];
$user_name = $result_array['user_username'];
echo '<a href = "home.php?mod=space&uid='.$userid.'">'.$result_array['user_username'].'</a>';
echo '<hr />';
}
}
}
require 'core/footer.php';
PHP
1
https://gitee.com/ica520/bbs_0.git
git@gitee.com:ica520/bbs_0.git
ica520
bbs_0
bbs_0
master

搜索帮助