php+mysql读取指定记录


测试用数据库文件test.sql这里下载,程序代码如下:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<?php
$conn = mysql_connect("localhost","root","dbmum");
mysql_select_db("test", $conn);
mysql_query("SET NAMES UTF8");
$key = '人';
$result = mysql_query("SELECT * FROM www_1500km_com where title like '%$key%'");
while($v = mysql_fetch_array($result)){
  echo $v['id'] . "," . str_replace($key,"<font color=red>$key</font>",$v['title']) . "<hr>";
}
mysql_close($conn);
?>

测试结果如下图: