我正在通过XMLHttpRequest对象进行实时搜索。 Javascript代码是正常的并且有效。
我的PHP代码不适合匹配结果列表。 (参见最后一张图片)
<?php
require './varmod/G.php';
require './varmod/g1.php';
// get the q parameter from URL
$q = htmlspecialchars($_GET['q']);
$hint = "";
echo "<ol>";
if ($q !== "") {
$q = strtolower($q);
$hint ="";
for ($i=0;$i<count($G);$i++) {
$x[$i] = $G[$i][0];
**//Here is something wrong??**
if (stristr($x[$i],$q)) {
if ($hint === "") {
$hint = $x[$i];
echo "<li><a href=\"https://medical-
dictionary.thefreedictionary.com/". $G[$i][1]."\">".$G[$i][1]."</a>-- 한글 :
<a href=\"https://www.google.com/search?q=\"".str_replace(" ","+",$G[$i][1]). "&newwindow=1&source=lnms&tbm=isch&sa=X&ved=0ahUKEwiUxfrjq9naAhUN5bwKHStsCWQQ_AUICigB&biw=1920&bih=949\" target='_blank'> ".$G[$i][2]. "</a> --3D : <iframe
id='embedded-human' frameBorder='0' width='600' height='450' allowFullScreen='true' src=\"".$G[$i][3]."\">3d</iframe</li>";
} else {
$hint = $x[$i];
echo "<li><a href=\"https://medical-dictionary.thefreedictionary.com/". $G[$i][1]."\">".$G[$i][1]."</a>-- 한글 : <a href=\"https://www.google.com/search?q=\"".str_replace(" ","+",$G[$i][0]). "&newwindow=1&source=lnms&tbm=isch&sa=X&ved=0ahUKEwiUxfrjq9naAhUN5bwKHStsCWQQ_AUICigB&biw=1920&bih=949\" target='_blank'> ".$G[$i][2]. "</a> --3D : <iframe
id='embedded-human' frameBorder='0' width='600' height='450' allowFullScreen='true' src=\"".$G[$i][3]."\">3d</iframe</li>";
}
}
}
}
我的./varmod/G.php代码如下所示
// 3d名称
$G=[
["Skeletal system","Skeletal system","골격계","https://human.biodigital.com/widget?be=2DNT&background=255,255,255,51,64,77&ui-cross-section=true&ui-dissect=true&ui-xray=true&uaid=2T5q8"],["Bones of head","Bones of head","머리뼈","https://human.biodigital.com/widget?be=2DNU&background=255,255,255,51,64,77&ui-cross-section=true&ui-dissect=true&ui-xray=true&uaid=2T5qK"],["Hyoid","Hyoid","설골","https://human.biodigital.com/widget?be=2F85&background=255,255,255,51,64,77&ui-cross-section=true&ui-dissect=true&ui-xray=true&uaid=2ThoY"],["Craniofacial bones","Craniofacial bones","두개안면뼈가","https://human.biodigital.com/widget?be=2DXR&background=255,255,255,51,64,77&ui-cross-section=true&ui-dissect=true&ui-xray=true&uaid=2T9mP"],["craniofacial bones","Right craniofacial bones","오른쪽두개안면뼈","https://human.biodigital.com/widget?be=2F86&background=255,255,255,51,64,77&ui-cross-section=true&ui-dissect=true&ui-xray=true&uaid=2Thoc"],["inferior nasal concha","Right inferior nasal concha","오른쪽하비갑개","https://human.biodigital.com/widget?be=2F88&background=255,255,255,51,64,77&ui-cross-section=true&ui-dissect=true&ui-xray=true&uaid=2Thol"],["lacrimal","Right lacrimal","오른쪽눈물","https://human.biodigital.com/widget?be=2F89&background=255,255,255,51,64,77&ui-cross-section=true&ui-dissect=true&ui-xray=true&uaid=2Thop"],...