ThinkPHP 3.1.3 实现网站查询数据关键字描红。开发疑难,功能开发,联系专业工程师 QQ467477957
查询逻辑:public function search_ok(){<br>
$Dao = M("shop");<br>
//echo $_POST[KeyWord];<br>
$where['name']=array('like',"%{$_POST[KeyWord]}%");<br>
$list = $Dao->where($where)->select();<br>
<br>
$this->assign("list", $list);<br>
//dump($list);<br>
$this->display('default/Index/search_ok');<br>
}
模板输出替换:<volist> <br>
<li>
<br>
<a>$vo['id']))}" target="_blank" title="{$vo.name}"><img alt="ThinkPHP 3.1.3 实现网站查询数据关键字描红" ></a><br>
<h4><a>$vo['id']))}" target="_blank" title="{$vo.name}"><!--{$vo.name}--><br>
<br>
<b> <?php $str=$vo[name]; $a="<b style='color:red;'> $_POST[KeyWord]</b>";echo str_ireplace("$_POST[KeyWord]",$a,$str);?><br>
<br>
</a></h4>
<br>
<div>
<br>
<p>¥<span>{$vo.price}.00</span></p>
<br>
</div>
<br>
<div>
<br>
<br>
<br>
<b>热荐</b><br>
</div>
<br>
</li>
<br>
</volist>
AD:真正免费,域名+虚机+企业邮箱=0元