mysql like模糊查询的问题
like的用法:
SELECT id FROM study_article WHERE pid = 0 AND title LIKE '%关键字%'
注意%外面是引号,里面是文字不能是字符串,也就是说不能把表单接收过来的值直接放在里面,要把值赋给一个变量;
例如:
$_html['keyword'] = $_POST['keyword'];
$_html = html($_html); //转义特殊字符,测试可忽略
$_keyword = $_html['keyword'];
$_rows = mysql_query("SELECT id FROM study_article WHERE pid = 0 AND title LIKE '%$_keyword%'");