数据库-在线词典

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', '学校');
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值