標籤:c style class a tar http
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>線上詞典</title>
<link href="shouye.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="toubu"><h1>線上詞典精彩無限</h1></div>
<div class="zhongjian"><img src="1.jpg"/>
<H1>查詢英文</H1>
<form action="wordprocess.php" method="post" >
請輸入英文:<input name="enword" type="text" />
<input name="type" type="hidden" value="search1" />
<input type="submit" value="查詢" />
</form>
<H1>查詢中文</H1>
<form action="wordprocess.php" method="post" >
請輸入中文:<input name="chword" type="text" />
<input name="type" type="hidden" value="search2" />
<input type="submit" value="查詢" />
</form></div>
<div class="zuihou">
<div>山東省邵氏科技股份有限公司</div>
<div class="zuihou">地址:山東省濟南市山大北路。支援人員:邵先生 郵箱: </div>
</div>
</body>
</html>
@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");//設定瀏覽器顯示的亂碼問題
require_once("412.php");
if(isset($_POST[‘type‘])){
$type=$_POST[‘type‘];
}else{
echo"輸入為空白";
echo"<a href=‘mainview.php‘>返回重新查詢</a>";
}
if($type=="search1"){
//接受英文單詞
if(isset($_POST[‘enword‘])){$en_word=$_POST[‘enword‘];}else{//主義 $_POST 函數是分大小寫
echo"輸入為空白";
echo"<a href=‘mainview.php‘>返回重新查詢</a>";
}
//看看資料庫中有沒有這條記錄
$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)){//主義:此處用的是關聯陣列
echo $en_word."對應的中文意思是: ".$row[‘chword‘];
echo"<br /><a href=‘mainview.php‘>返回重新查詢</a>";}
else{
echo"查詢沒有這個詞條";
echo"<br /><a href=‘mainview.php‘>返回重新查詢</a>";}
mysql_free_result($res);
}
if($type=="search2"){
//接受中文
if(isset($_POST[‘chword‘])){$ch_word=$_POST[‘chword‘];}else{//主義 $_POST 函數是分大小寫
echo"輸入為空白";
echo"<a href=‘mainview.php‘>返回重新查詢</a>";
}
//看看資料庫中有沒有這條記錄
$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)){//主義:此處用的是關聯陣列
echo $ch_word.‘對應的意思是: ‘.$row[‘enword‘];
echo"<br />";
}
echo"<br /><a href=‘mainview.php‘>返回重新查詢</a>";}
else{
echo"查詢沒有這個詞條";
echo"<br /><a href=‘mainview.php‘>返回重新查詢</a>";}
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("連結資料庫失敗".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);}
}
?>