欢迎访问 舍力博客(www.shuyong.net)
$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>
留言/评论:◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。