发表时间:2014-09-05来源:网络
[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/>";

CI框架连接数据库配置操作以及多数据库操作
asp 简单读取数据表并列出来 ASP如何快速从数据库读取大量数据
C语言关键字及其解释介绍 C语言32个关键字详解
C语言中sizeof是什么意思 c语言里sizeof怎样用法详解
PHP中的魔术方法 :__construct, __destruct , __call, __callStatic,__get, __set, __isset, __unset , __sleep,
将视频设置为Android手机开机动画的教程
PHP中的(++i)前缀自增 和 (i++)后缀自增
最简单的asp登陆界面代码 asp登陆界面源代码详细介绍
常用dos命令及语法
PHP中include和require区别之我见
桩桩充电官方版下载v2.4.2 安卓版
80.31MB |生活服务
中国天气通专业版最新版下载v9.1.0.4 官方安卓版
56.95MB |系统工具
新疆联通网上营业厅官方版(又名中国联通)下载v12.8 安卓客户端
118.17MB |生活服务
联通手机营业厅关怀版(又名中国联通)下载v12.8 安卓最新版
118.17MB |生活服务
28hse香港租屋网APP下载v3.14.0 手机版
51.07MB |生活服务
唐山联通掌上营业厅(中国联通)下载v12.8 安卓版
118.17MB |生活服务
新货多app下载v2.6.2 安卓最新版
65.91MB |生活服务
东梨短剧免费正版app下载v4.0.3 安卓版
61MB |影音播放
2014-09-05
2022-03-20
2022-03-21
2022-03-24
2014-09-05
2014-09-05
2015-07-05
2014-09-05
2014-09-05
2022-03-21