<fh-function>
$keyword=t($_REQUEST["keyword"]);
$page=$_GET["page"];
if($page==""){
  $page=1;
}

$sql="select count(*) as L_count from
(select N_id as id,N_title as title,N_pic as pic,N_content as content,'newsinfo' as type from sl_news where N_del=0 and N_sh=1 and (N_title like '%".$keyword."%' or N_content like '%".$keyword."%' )
union select S_id as id,S_title as title,S_pic as pic,S_content as content,'news' as type from sl_nsort where S_del=0 and (S_title like '%".$keyword."%' or S_content like '%".$keyword."%' )
union select C_id as id,C_title as title,C_pic as pic,C_content as content,'courseinfo' as type from sl_course where C_del=0 and (C_title like '%".$keyword."%' or C_content like '%".$keyword."%' )
union select S_id as id,S_title as title,S_pic as pic,S_content as content,'course' as type from sl_usort where S_del=0 and (S_title like '%".$keyword."%' or S_content like '%".$keyword."%' )
union select P_id as id,P_title as title,P_pic as pic,P_content as content,'productinfo' as type from sl_product where P_del=0 and P_sh=1 and (P_title like '%".$keyword."%' or P_content like '%".$keyword."%' )
union select S_id as id,S_title as title,S_pic as pic,S_content as content,'product' as type from sl_psort where S_del=0 and (S_title like '%".$keyword."%' or S_content like '%".$keyword."%' )
union select T_id as id,T_title as title,T_pic as pic,T_content as content,'text' as type from sl_text where T_del=0 and (T_title like '%".$keyword."%' or T_content like '%".$keyword."%' ))a";
$result = mysqli_query($conn, $sql);
$row = mysqli_fetch_assoc($result);
$L_count=$row["L_count"];

$page_num=intval($L_count/21)+1;
if($L_count%21 ==0){
  $page_num=$page_num-1;
}
</fh-function>
<!DOCTYPE html>
<html><head>
		<meta charset="UTF-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no">
		<meta name="apple-mobile-web-app-title" content="Modown">
		<meta http-equiv="Cache-Control" content="no-siteapp">
		<title>搜索<fh-function> $api=$api.$keyword;</fh-function> -[fh_title]</title>
		<link href="media/[fh_ico]" rel="shortcut icon" />
		<meta name="description" content="[fh_description]" />
		<meta name="keywords" content="[fh_keyword]" />
		<link rel="stylesheet" href="template/t16/assets/web/styles/libs.css?1638194128">
		<link rel="stylesheet" href="template/t16/assets/web/styles/style.css?1638194128">
		<link rel="stylesheet" href="template/t16/assets/web/fonts/css/fontawesome-all.min.css">
		<link rel="stylesheet" href="template/t16/assets/styles/swiper.min.css">
		<link href="css/Pager.css" rel="stylesheet" type="text/css" />
		<script type="text/javascript" src="template/t16/assets/scripts/jquery.min.js"></script>
		<script type="text/javascript" src="template/t16/assets/scripts/swiper.min.js"></script>
		<script type="text/javascript" src="template/t16/assets/scripts/layer.js"></script>
		<link rel="stylesheet" href="template/t16/assets/scripts/theme/default/layer.css?v=3.3.0" id="layuicss-layer">
		<script type="text/javascript" src="template/t16/assets/scripts/bjplus.js"></script>
		<script type="text/javascript" src="template/t16/assets/scripts/tmodjs.js"></script>
		<script type="text/javascript" src="template/t16/assets/scripts/clipboard.min.js"></script>	

	</head>
<body>	
[fh_header]
<style>
.grid a:visited {color:#2196F3;}
</style>
<div class="pages">
	<div class="banner-archive">
		<div class="container">
			<h1 class="archive-title">搜索：<fh-function> $api=$api.$keyword;</fh-function></h1>
			<div class="search-form">
				<div class="site-search-form">
					<input class="search-input" id="names3" type="text" placeholder="输入关键词，多个关键词用空格分开" value="<fh-function> $api=$api.$keyword;</fh-function>">
					<button class="search-btn" id="search3"><i class="icon icon-search"></i></button>
				</div>
			</div>
		</div>
	</div>
	<div class="main">
		<div class="container clearfix" style="min-height: calc(100vh - 399px);">
			

						            <div id="container" class="lists clearfix">

<fh-function>
if($keyword==""){
  $api=$api."请输入要查询的关键词！";
}else{

$sql="select id,title,pic,content,type from(
select N_id as id,N_title as title,N_pic as pic,N_content as content,'newsinfo' as type from sl_news where N_del=0 and N_sh=1 and (N_title like '%".$keyword."%' or N_content like '%".$keyword."%' )
union select S_id as id,S_title as title,S_pic as pic,S_content as content,'news' as type from sl_nsort where S_del=0 and (S_title like '%".$keyword."%' or S_content like '%".$keyword."%' )
union select P_id as id,P_title as title,P_pic as pic,P_content as content,'productinfo' as type from sl_product where P_del=0 and P_sh=1 and (P_title like '%".$keyword."%' or P_content like '%".$keyword."%' )
union select S_id as id,S_title as title,S_pic as pic,S_content as content,'product' as type from sl_psort where S_del=0 and (S_title like '%".$keyword."%' or S_content like '%".$keyword."%' )
union select C_id as id,C_title as title,C_pic as pic,C_content as content,'courseinfo' as type from sl_course where C_del=0 and (C_title like '%".$keyword."%' or C_content like '%".$keyword."%' )
union select S_id as id,S_title as title,S_pic as pic,S_content as content,'course' as type from sl_usort where S_del=0 and (S_title like '%".$keyword."%' or S_content like '%".$keyword."%' )
union select T_id as id,T_title as title,T_pic as pic,T_content as content,'text' as type from sl_text where T_del=0 and (T_title like '%".$keyword."%' or T_content like '%".$keyword."%' ))a limit ".(($page-1)*21).",21";

$result = mysqli_query($conn,  $sql);
if (mysqli_num_rows($result) > 0) {
while($row = mysqli_fetch_assoc($result)) {


$search_info=$search_info.'<div class="grid">
	<div class="img">
		<a href="?type='.$row['type'].'&id='.$row['id'].'" target="_blank" title="'.str_Replace($keyword,'<font color=\'red\'>'.$keyword.'</font>',$row['title']).'">
			<img src="'.pic(splitx($row['pic'],'|',0)).'" class="thumb" style="width: 75px">
		</a>
	</div>
	<h3>
		<a href="?type='.$row['type'].'&id='.$row['id'].'" target="_blank" title="'.str_Replace($keyword,'<font color=\'red\'>'.$keyword.'</font>',$row['title']).'">'.str_Replace($keyword,'<font color=\'red\'>'.$keyword.'</font>',$row['title']).'</a>
	</h3>
	<div style="text-overflow: -o-ellipsis-lastline;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;font-size: 12px;color: #666"><a href="?type='.$row['type'].'&id='.$row['id'].'" target="_blank" title="'.str_Replace($keyword,'<font color=\'red\'>'.$keyword.'</font>',$row['title']).'">'.str_replace($keyword,'<font color=\'red\'>'.$keyword.'</font>',mb_substr(strip_tags($row['content']),0,100,'utf-8')).'</a></div>
	
	</div>
	';

    }
  $api=$api.$search_info;
}else{
  $api=$api."抱歉！未找到“".$keyword."”的相关内容，请尝试其他关键词！";
}
}
                    
</fh-function>





	</div></div>

<div id="pager"></div>

		</div>
	</div>
</div>

<script type="text/javascript">
var nowPage = 1; 
var ajaxUrl = "/index.php?mod=mobile&act=search&do=article&m=eshop&key=%E7%B2%BE%E7%A5%9E&beid=10";
var get_status = true;
$(function () {
    function getData(page) {
		if(get_status){			
			nowPage++;
			var loads = layer.load(2);
			$.post(ajaxUrl, {page: page}, function (data) {
				layer.close(loads);
				var jsonObj = JSON.parse(data);
				if (jsonObj.result.list.length <= 0 && page==1) {
					$(".infoimg").show();
				}	
				if (jsonObj.result.list.length > 0) {
					$("#credit_loading").show();
					insertDiv(jsonObj.result.list);					
				}else{
					get_status = false;
					$('#credit_loading').html('<div class="loading_bd">暂时没有更多了</div>');
				}					
			});
		}
    }
	
    getData(1);
  
    function insertDiv(res) {  
        var mainDiv =$("#container");
        var chtml = '';  
        for (var i = 0; i < res.length; i++) {
									chtml += '<div class="grid">';
			chtml += '<div class="img">';
			chtml += '<a href="/index.php?mod=mobile&act=article&do=article&m=eshop&beid=10&id=' + res[i].id + '" target="_blank" title="' + res[i].article_titles + '">';
			chtml += '<img src="' + res[i].figure2 + '" class="thumb">';
			chtml += '</a>';
			chtml += '</div>';
			chtml += '<h3><a href="/index.php?mod=mobile&act=article&do=article&m=eshop&beid=10&id=' + res[i].id + '" target="_blank" title="' + res[i].article_titles + '">' + res[i].article_title + '</a></h3>';
			chtml += '<p><a href="/index.php?mod=mobile&act=article&do=article&m=eshop&beid=10&id=' + res[i].id + '" target="_blank" title="' + res[i].article_titles + '">' + res[i].article_title + '</a></p>';
			chtml += '<div class="grid-meta">';
			chtml += '<span class="time"><i class="icon icon-time"></i> ' + res[i].createtime + '</span>';
			chtml += '<span class="views"><i class="icon icon-eye"></i> ' + res[i].article_readnum + '</span>';
			chtml += '<span class="comments"><i class="icon icon-posts"></i> ' + res[i].figure1 + 'M</span>';				
			chtml += '</div>';
			chtml += '</div>';
		    			        }        
		mainDiv.append(chtml);
    }  
  
    //定义鼠标滚动事件
	var scroll_loading = false;
    $(window).scroll(function(){
	　　var scrollTop = $(this).scrollTop();
	　　var scrollHeight = $(document).height();
	　　var windowHeight = $(this).height();
	　　if(scrollTop + windowHeight >= scrollHeight && !scroll_loading){
			scroll_loading = true;
			getData(nowPage);  
			scroll_loading = false;
	　　}
	});
	
    $("#btn_Page").click(function () {
        getData(nowPage);
    });  
});
</script>	
<script type="text/javascript">
$(document).ready(function () {
    $("#names3").on('keypress',function(e) {
        var keycode = e.keyCode;
		var searchkey = $.trim($("#names3").val());
        if(keycode=='13') {  
            if(searchkey == ''){	
			    layer.msg('请输入搜索关键词');
		    }else{
                window.location.href = "?type=search&keyword="+searchkey;
		    }     
        }
    });		
	$("#search3").click(function(){
		var searchkey = $.trim($("#names3").val());
		if(searchkey == ''){
			layer.msg('请输入关键词');			
		}else{
            window.location.href = "?type=search&keyword="+searchkey;
		}
	});
});	
</script>
<script src="js/jquery.pager.js" type="text/javascript"></script>
<script>


$(document).ready(function() {
    $("#pager").pager({ pagenumber: <fh-function> $api=$api.$page;</fh-function>, pagecount: <fh-function> $api=$api.$page_num;</fh-function>, buttonClickCallback: PageClick });
});

PageClick = function(pageclickednumber) {
  window.location="?type=search&keyword=<fh-function> $api=$api.$keyword;</fh-function>&page="+pageclickednumber;
}
</script>
[fh_footer]
</body></html>