db"> 跳转到主内容
极星编程网:以代码为星,赴技术山海!

《php---mysql简单应用---在线词典》

[html]Insert title here

请输入您要查找的英文单词:

Insert title here

请输入您要查找的英文单词:

[php] view plaincopyprint?php
conn = mysql_connect($this->host, $this->user, $this->password);if (!$this->conn){die("连接数据库失败".mysql_error());}//选择数据库mysql_select_db($this->db,$this->conn);mysql_query("set names utf8");}function findchword($enword){$sql = "select * from words where enword ='".$enword."'limit 0,10";$res = mysql_query($sql,$this->conn) or die(mysql_error());if (!$res){return 0;//失败}else{$row = mysql_fetch_assoc($res);return $row['chword'];}}}php

conn = mysql_connect($this->host, $this->user, $this->password);if (!$this->conn){die("连接数据库失败".mysql_error());}//选择数据库mysql_select_db($this->db,$this->conn);mysql_query("set names utf8");}function findchword($enword){$sql = "select * from words where enword ='".$enword."'limit 0,10";$res = mysql_query($sql,$this->conn) or die(mysql_error());if (!$res){return 0;//失败}else{$row = mysql_fetch_assoc($res);return $row['chword'];}}}[php]php
findchword($_POST['enword']);if ($chword){echo $_POST['enword']."对应的中文意思是:".$chword."";}else{echo "未查询到结果!

";}}else{echo "未获取任何输入!

";}echo "点击返回";php
findchword($_POST['enword']);if ($chword){echo $_POST['enword']."对应的中文意思是:".$chword."";}else{echo "未查询到结果!

";}}else{echo "未获取任何输入!

";}echo "点击返回";

相关文章