作者:-苏小澄11m | 来源:互联网 | 2018-03-23 18:30
1. [代码] [PHP]代码
include "linkdb.php";
header("Content-type:text/html;charset=utf-8");
$word=$_GET["word"];
$search=$_GET["searc"];
$sqlstr="SELECT * from word where word='".$word."'";
$rst=mysql_query($sqlstr);
list($word,$exp)=mysql_fetch_row($rst);
echo '
'.$word.' '.$exp.'
';
if($word==''){
echo '
查无记录……
';
}
?>
2. [代码] [PHP]代码
/////////linkdb.php//////////
/////////link database///////
$mydb=mysql_pconnect('localhost','root','lijun');
mysql_query("SET NAMES 'utf8'");
if(!$mydb)
{
//echo "连结失败....";
}else{
//echo "连接成功....";
}
$db=mysql_select_db('mydatautf8',$mydb);
if($db){
//echo "数据库连接正确...";
}else{
//echo "数据库连结错误....";
}
?> 3. [文件]
dicsug.php
///////////词典suggest响应页面/////////////
include "linkdb.php";
header("Content-type:text/html;charset=gb2312");
$word=$_GET["word"];
$sqlstr="SELECT word from word where word like '".$word."%'";
$rst=mysql_query($sqlstr);
$i=0;
$w['0']='';
$w['1']='';
$w['2']='';
$w['3']='';
$w['4']='';
$w['5']='';
$w['6']='';
$w['7']='';
$w['8']='';
$w['9']='';
while(($row=mysql_fetch_row($rst))&&$i<=9){
list($w[&#39;&#39;.$i.&#39;&#39;])=mysql_fetch_row($rst);
$i++;
}
echo $w["0"].&#39; &#39;.$w["1"].&#39; &#39;.$w["2"].&#39; &#39;.$w["3"].&#39; &#39;.$w["4"].&#39; &#39;.$w["5"].&#39; &#39;.$w["6"].&#39; &#39;.$w["7"].&#39; &#39;.$w["8"].&#39; &#39;.$w["9"];
?>
4. [代码] [PHP]代码
5. [图片] printscreen1.png