Online dictionary PHP

Source: Internet
Author: User

<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/>
<title> Online Dictionaries </title>
<link href= "Shouye.css" rel= "stylesheet" type= "Text/css"/>

<body>
<div class= "Toubu" ><div class= "Zhongjian" >
<H1> Inquiry in English </H1>
<form action= "wordprocess.php" method= "POST" >
Please input in English: <input name= "Enword" type= "text"/>
<input name= "type" type= "hidden" value= "Search1"/>
<input type= "Submit" value= "Query"/>
</form>
<H1> Search Chinese </H1>
<form action= "wordprocess.php" method= "POST" >
Please input Chinese: <input name= "Chword" type= "text"/>
<input name= "type" type= "hidden" value= "Search2"/>
<input type= "Submit" value= "Query"/>
</form></div>
<div class= "Zuihou" >
<div> Shandong Shaw Technology Co., Ltd. </div>
<div class= "Zuihou" > Address: Great North Road, Jinan Mountain, Shandong province. Technical support: Mr. Shao e-mail: </div>

</div>


</body>

@charset "Utf-8";
. Zuihou {
font-family: "Comic Sans MS", cursive;
font-size:15px;
Text-align:center;
Background-color: #CCC;
Float:left;
height:20%;
width:100%;
}
. toubu{
font-size:24px;
Text-align:center;
Background-color: #CCC;
Float:left;
height:20%;
width:100%;
Font-family:verdana, Geneva, Sans-serif;
}
. Zhongjian {
position:relative;
Text-align:center;
Border:thin solid silver;
width:950px;
Height:inherit;
Background-color: #FF9;
Margin:auto;
padding:1px;
Background-position:center;
Clear:both;
Float:none;

}
<? Php
Header ("Content-type:text/html;charset=utf-8");//Setting the browser display garbled problem
Require_once ("412.php");
if (Isset ($_post[' type ')) {
$type =$_post[' type '];
}else{
echo "Input is empty";
echo "<a href= ' mainview.php ' > Return to query </a> again";
}
if ($type = = "Search1") {
Accept English words
if (Isset ($_post[' Enword ')) {$en _word=$_post[' Enword '];} The else{//$_post function is divided into uppercase and lowercase
echo "Input is empty";
echo "<a href= ' mainview.php ' > Return to query </a> again";
}
See if there's any record in the database.
$sql = "Select Chword from words where enword= '". $en _word. "' Limit 0,1 ';

$sqltool =new Sqltool ();

$res = $sqltool->execute_dql ($sql);
if ($row =mysql_fetch_assoc ($res)) {///doctrine: Associative arrays are used here
echo $en _word. " The corresponding Chinese meaning is: ". $row [' Chword '];
echo "<br/><a href= ' mainview.php ' > Return to query </a> again";}
else{
echo "Query does not have this term";
echo "<br/><a href= ' mainview.php ' > Return to query </a> again";}

Mysql_free_result ($res);
}
if ($type = = "Search2") {
Accept Chinese
if (Isset ($_post[' Chword ')) {$ch _word=$_post[' Chword '];} The else{//$_post function is divided into uppercase and lowercase
echo "Input is empty";
echo "<a href= ' mainview.php ' > Return to query </a> again";
}
See if there's any record in the database.
$sql = "Select Enword from words where chword like '%". $ch _word. " %‘";

$sqltool =new Sqltool ();

$res = $sqltool->execute_dql ($sql);
if (mysql_num_rows ($res)) {
while ($row =mysql_fetch_assoc ($res)) {///doctrine: Associative arrays are used here
echo $ch _word. ' The corresponding meaning is: '. $row [' Enword '];
echo "<br/>";
}
echo "<br/><a href= ' mainview.php ' > Return to query </a> again";}
else{

echo "Query does not have this term";
echo "<br/><a href= ' mainview.php ' > Return to query </a> again";}

Mysql_free_result ($res);
}
?>

<?php//412.php
Class sqltool{
Private $conn;
Private $host = "localhost";
Private $user = "root";
Private $password = "";
Private $db = "WORDDB";

function Sqltool () {
$this->conn=mysql_connect ($this->host, $this->user, $this->password);
if (! $this->conn) {
Die ("link Database failed". Mysql_error ());
}
mysql_select_db ($this->db, $this->conn) or Die (Mysql_error ());
mysql_query ("Set names UTF8");

}
function Execute_dql ($sql) {
$res =mysql_query ($sql);
return $res;
}
function Execute_dml ($sql) {
$b =mysql_query ($sql, $this->conn);
if (! $b) {
return 0;
}
else{
if (Mysql_affected_rows ($this->conn) >0) {
return 1;}
else{
return 2;
}
}
Mysql_close ($conn);}
}
?>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.