1

我试过这个查询,

$str =$_POST['val'].'%';
$query = mysql_query("select * from table WHERE title LIKE '$str' ORDER BY createdtime DESC LIMIT 0, 70 ");

但它仅在单词的开头搜索匹配项。不要在世界其他地方搜索。例如,当我在“golden”一词中搜索模式“gold”时,它检测正确。但不是在中间或结尾或其他地方,“a gold”或“a gold”之类的词将无法正确显示。

4

2 回答 2

2
$query = mysql_query("select * from table WHERE title LIKE '%$str%' ORDER BY createdtime DESC LIMIT 0, 70 ");
于 2012-07-18T11:40:03.720 回答
1

你需要通过%word%

$str =$_POST['val'];

$query = mysql_query("select * from table WHERE title LIKE '%$str%' ORDER BY createdtime DESC LIMIT 0, 70 ");
于 2012-07-18T11:41:35.877 回答