您的位置:首页 > 数据库

数据库-在线词典

2016-10-13 10:37 323 查看
mainView.php代码如下:

<html>
<head>
<title>在线词典</title>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
</head>
<body>
<img src="ciba.png" />
<h>查询英语</h1>
<form action="???" method="enword" />
<input type="hidden" value="search" name="type" />
<input type="submit" value="查询" />
</form>
</body>
</html>


wordProccess.php

<?php
//引用工具类查询方法
require_once 'sqlTool.class.php';

//接受英文单词
if(isset($_POST['enword'])) {
$en_word=$_POST['enword'];
}else{
echo "输入为空";
echo "<a href='mainView.php'>返回重新查询</a>";
}

//查看数据库中有没有这条记录
$sql="select * from 表名 where 条件" limit 0,1;  // 查询一条即返回

//设计表,查询(面向对象)
$sqlTool = new SqlTool();
$res = $sqlTool->execute_dql($res);  //查询方法
if($row = mysql_fetch_row($res)) {    //
echo $en_word."对应的中文意思是--".$row[2];
} else {
echo "查询没有这个词条";
echo "<br/><a href = 'mainView.php'>返回重新查询</a>";
}

?>


创建表:

//创建数据库
create database worddb;

create table words(
id int primary key auto_increment,
enword varchar(32) not null,
chword varchar(256) not null
)

//导入数据
insert into words(enword,chword) values('boy', '男孩');
insert into words(enword, chword) value('school', '学校');
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: