我有这个代码来过滤我想要的表格'labs'中的名称,结果超过16K:
$mysqli = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME);
$mysqli->set_charset("utf8");
$text = $mysqli->real_escape_string($_GET['term']);
$query = "SELECT name FROM labs WHERE name LIKE '%$text%'";
$result = $mysqli->query($query);
$json = '[';
$first = true;
while($row = $result->fetch_assoc()){
if (!$first) { $json .= ','; } else { $first = false; }
$json .= '{"value":"'.$row['name'].'"}';
}
$json .= ']';
echo $json;
问题是当我将前两个或多个字母插入输入时总是向我显示该表行中的整个数据,例如,如果我放der
,我需要结果只显示数据名称中包含der
但现在始终显示整行
答案 0 :(得分:0)
InnoDB默认将最小字长设置为3。当您键入3个或更少的字符数时,这可能会导致它返回所有结果。请参阅下面的参考。尝试增加计数
https://dev.mysql.com/doc/refman/5.7/en/fulltext-fine-tuning.html
如果您想从左到右匹配,那么您可以像
一样使用它<div id="q-numbers">
<div>Defect Incident as of <span id="qval1"></span></div>
<div class="table">
<div>
<div>Days since last escape</div>
<div>Best Streak
<br/>(since 4/5/16)</div>
</div>
<div>
<div class="square orange"><span id="qval2">23</span></div>
<div class="square blue"><span id="qval3">44</span></div>
</div>
</div>
</div>