发表时间:2015-05-27来源:网络
[html]
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<form action="search.php" method="post">
请输入您要查找的英文单词:<br/>
<input type="text" name="enword"/><br/>
<input type="submit" value="提交"/><br/>
</form>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<form action="search.php" method="post">
请输入您要查找的英文单词:<br/>
<input type="text" name="enword"/><br/>
<input type="submit" value="提交"/><br/>
</form>
</body>
</html>[php] view plaincopyprint?
<?php
class DicTool{
private $conn;
private $host = "localhost";
private $user = "root";
private $password = "123";
private $db = "test";
//构造函数,初始化数据,连接数据库
function __construct(){
$this->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
class DicTool{
private $conn;
private $host = "localhost";
private $user = "root";
private $password = "123";
private $db = "test";
//构造函数,初始化数据,连接数据库
function __construct(){
$this->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
header("Content-Type: text/html; charset=UTF-8");
include_once 'DicTool.class.php';
$dicTool = new DicTool();
if (isset($_POST['enword'])){
$chword = $dicTool->findchword($_POST['enword']);
if ($chword){
echo $_POST['enword']."对应的中文意思是:".$chword."<br/>";
}else{
echo "未查询到结果!<br/>";
}
}else{
echo "未获取任何输入!<br/>";
}
echo "<a href='find.html'>点击返回<a/><br/>";
<?php
header("Content-Type: text/html; charset=UTF-8");
include_once 'DicTool.class.php';
$dicTool = new DicTool();
if (isset($_POST['enword'])){
$chword = $dicTool->findchword($_POST['enword']);
if ($chword){
echo $_POST['enword']."对应的中文意思是:".$chword."<br/>";
}else{
echo "未查询到结果!<br/>";
}
}else{
echo "未获取任何输入!<br/>";
}
echo "<a href='find.html'>点击返回<a/><br/>";

下一篇:php基础算法
CI框架连接数据库配置操作以及多数据库操作
asp 简单读取数据表并列出来 ASP如何快速从数据库读取大量数据
C语言关键字及其解释介绍 C语言32个关键字详解
C语言中sizeof是什么意思 c语言里sizeof怎样用法详解
PHP中的魔术方法 :__construct, __destruct , __call, __callStatic,__get, __set, __isset, __unset , __sleep,
PHP中的(++i)前缀自增 和 (i++)后缀自增
将视频设置为Android手机开机动画的教程
最简单的asp登陆界面代码 asp登陆界面源代码详细介绍
常用dos命令及语法
PHP中include和require区别之我见
扬子餐饮app下载v1.4.9 安卓版
21.47MB |生活服务
云视通生活最新版(改名小维智慧家庭)下载v5.1.16 安卓官方版
90.93MB |拍摄美化
企业查询宝app下载v9.0.5 安卓版
65.83MB |商务办公
云上南阳app下载v5.6.0 安卓官方版
135.12M |资讯阅读
蓝舞者app拉丁舞音乐下载v3.6.40 安卓版
101.53MB |学习教育
neye3c摄像头app下载v4.5.5.2 安卓官方版
168.42MB |拍摄美化
布仓软件下载v4.1.9 安卓最新版
31.46MB |生活服务
zdfit软件下载v2.0.10 安卓官方版
113.91MB |生活服务
2014-09-05
2022-03-20
2022-03-21
2022-03-24
2014-09-05
2014-09-05
2015-07-05
2014-09-05
2022-03-21
2014-09-05