<?php
include('mysql_inc.php');$db=new mysql('localhost','root','','test','GBK'); if($_GET[key]){
$sql="select * from `php100` where name like '%$_GET[key]%'";
$q=$db->query($sql);
while($r=$db->fetch_array($q)){ preg_replace("/($_GET[key])/i","<font color=red><b>\\1</b></font>",$r[name]); echo $r[name]."<br>";
}
}
?> <form action="" method="get">
关键字:
<input type="text" name="key"/>
<input type="submit" name="sub" value="全站搜索"/>
</form>连接数据库是成功的,就是不能高亮显示搜索关键字,一直找不到,结果,正则应该也没有错啊,大家帮我看看把。
include('mysql_inc.php');$db=new mysql('localhost','root','','test','GBK'); if($_GET[key]){
$sql="select * from `php100` where name like '%$_GET[key]%'";
$q=$db->query($sql);
while($r=$db->fetch_array($q)){ preg_replace("/($_GET[key])/i","<font color=red><b>\\1</b></font>",$r[name]); echo $r[name]."<br>";
}
}
?> <form action="" method="get">
关键字:
<input type="text" name="key"/>
<input type="submit" name="sub" value="全站搜索"/>
</form>连接数据库是成功的,就是不能高亮显示搜索关键字,一直找不到,结果,正则应该也没有错啊,大家帮我看看把。
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货