现在的位置: 首页 > 综合 > 正文

高亮显示关键字

2013年06月22日 ⁄ 综合 ⁄ 共 2239字 ⁄ 字号 评论关闭


<!--
/* Font Definitions */
@font-face
{font-family:宋体;
panose-1:2 1 6 0 3 1 1 1 1 1;
mso-font-alt:SimSun;
mso-font-charset:134;
mso-generic-font-family:auto;
mso-font-pitch:variable;
mso-font-signature:3 135135232 16 0 262145 0;}
@font-face
{font-family:"/@宋体";
panose-1:2 1 6 0 3 1 1 1 1 1;
mso-font-charset:134;
mso-generic-font-family:auto;
mso-font-pitch:variable;
mso-font-signature:3 135135232 16 0 262145 0;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{mso-style-parent:"";
margin:0cm;
margin-bottom:.0001pt;
text-align:justify;
text-justify:inter-ideograph;
mso-pagination:none;
font-size:10.5pt;
mso-bidi-font-size:12.0pt;
font-family:"Times New Roman";
mso-fareast-font-family:宋体;
mso-font-kerning:1.0pt;}
p.MsoHeader, li.MsoHeader, div.MsoHeader
{margin:0cm;
margin-bottom:.0001pt;
text-align:center;
mso-pagination:none;
tab-stops:center 207.65pt right 415.3pt;
layout-grid-mode:char;
border:none;
mso-border-bottom-alt:solid windowtext .75pt;
padding:0cm;
mso-padding-alt:0cm 0cm 1.0pt 0cm;
font-size:9.0pt;
font-family:"Times New Roman";
mso-fareast-font-family:宋体;
mso-font-kerning:1.0pt;}
p.MsoFooter, li.MsoFooter, div.MsoFooter
{margin:0cm;
margin-bottom:.0001pt;
mso-pagination:none;
tab-stops:center 207.65pt right 415.3pt;
layout-grid-mode:char;
font-size:9.0pt;
font-family:"Times New Roman";
mso-fareast-font-family:宋体;
mso-font-kerning:1.0pt;}
/* Page Definitions */
@page
{mso-page-border-surround-header:no;
mso-page-border-surround-footer:no;}
@page Section1
{size:595.3pt 841.9pt;
margin:72.0pt 90.0pt 72.0pt 90.0pt;
mso-header-margin:42.55pt;
mso-footer-margin:49.6pt;
mso-paper-source:0;
layout-grid:15.6pt;}
div.Section1
{page:Section1;}
-->

 

高亮显示关键字

效果:

 

实现方法及步骤:点击搜索按钮,跳转到
serch.php
并查处含有关键字的商品

代码:

$query 
= mysql_query($sql);

    
$num2=
mysql_num_rows($query);      
  

   
 
while($rs=mysql_fetch_array($query)){        

   
   
$sort2[]=array(     

          
 
'id'        

=> $rs['id'],

          
//
'product_name'=> $rs['product_name'],

          
 
'product_name'=>preg_replace("/($keyword)/i","<font
color=red><b>//1</b></font>",$rs[product_name]),

          
 
'product_hao' => $rs['product_hao'],

          
 
'picture'    

=> $rs['picture'],

          
 
'product_xin' => $rs['product_xin']

   
   
);

   
// print_r($sort2);

   
 
}

}

$tpl ->assign('pagenav',$pagenav);

 
$tpl ->
assign('sort',$sort);

 
$tpl ->
assign('sort2',$sort2);

 
$tpl->display('search.htm');

?>

 

抱歉!评论已关闭.