标签:orm order mod ons order by comm lse cti MLOG
Emlog手机版好像没有给予获取搜索的相关功能,反正也是无聊状态中,今天就给大家详细的讲解一下此功能的实现方法,希望能够帮到有需要的朋友
首先,我们要在手机版模板的m文件夹的index.php中找到代码
$action = isset($_GET[‘action‘]) ? addslashes($_GET[‘action‘]) : ‘‘;
在其下方加入代码
$slkey = isset($_GET[‘keyword‘]) ? addslashes($_GET[‘keyword‘]) : ‘‘;
在代码
$page_url = pagination($lognum, $index_lognum, $page, $pageurl);
后面加入代码
if(!empty($slkey)){//搜索
$Log_Model = new Log_Model();
$page = isset($_GET[‘page‘]) ? abs(intval ($_GET[‘page‘])) : 1;
$site_title = ‘搜索关键词:‘.$slkey.‘价格表‘;
$pageurl = ‘‘;
if(is_numeric($slkey)){
$sqlSegment = "and (huohao =‘{$slkey}‘) order by date desc";}else{
$sqlSegment = "and title like ‘%{$slkey}%‘ order by date desc";}
$lognum = $Log_Model->getLogNum(‘n‘, $sqlSegment);
$pageurl = "./?keyword=$slkey&page=";
$logs = $Log_Model->getLogsForHome($sqlSegment, $page, $index_lognum);
$page_url = pagination($lognum, $index_lognum, $page, $pageurl);
}
调用方法:
<form action="./" method="get" enctype="multipart/form-data" onSubmit="return slkeyword();">
<input name="keyword" placeholder="输入货号或者产品名称" />
<button type="submit"/>搜索</button>
</form>
标签:orm order mod ons order by comm lse cti MLOG
原文地址:https://www.cnblogs.com/lijingnini/p/12515948.html