一、首先 查詢介面 **:
效果如圖:
二、建立資料庫 表 以及插入 資料
三、封裝 資料庫操作工具類 sqltools.class.php://建立個資料庫
create
database word;
use word;
//設計表 英文-》中文 中文-》英文
create
table words(
id int
primary
key auto_increment,
enword varchar(32) not
null,
chword varchar(256) not
null
);setnames gbk;
insert
into words(enword,chword) values('boy','男孩');
insert
into words(enword,chword) values('school','學校');
insert
into words(enword,chword) values('word','詞語,說話,訊息');
insert
into words(enword,chword) values('speek','說話,談話');
四、對資料庫操作的主邏輯 wordprogress.php<?php
class
sqltools
mysql_select_db($this->db,$this->conn);
mysql_query("set names utf8");}*/
function
sqltools
($host,$user,$passwd,$db)
mysql_select_db($this->db,$this->conn);
mysql_query("set names utf8");
}//查詢
function
execute_dql
($sql)
//增刪改
function
execute_dml
($sql)elseelse}}
//關閉資源 和 鏈結
function
cloase_res
() //獲得表頭 用->name方法獲取
function
show_tab_head_field
() }
//獲取表 資料行
function
show_tab_lines
() }
//獲取表 資料列
function
show_tab_colums
() }
}?>
<?php
header("content-type:text/html;charset=utf-8");
//初始化工具類
require_once
"sqltools.class.php";
$tools = new sqltools('localhost','root','159357','word');
$res = null;
//接受type
if(isset($_post['type']))else
if($type == "search")else
//查詢資料庫
$sql = "select chword from words where enword='$en_word' limit 0,1";
$res = $tools->execute_dql($sql);//查出一條資料
if($row = mysql_fetch_assoc($res))else
}else
if($type == "search1")else
//查詢資料庫
$sql = "select enword from words where chword like '%".$ch_word."%'";
$res = $tools->execute_dql($sql);//查出一條資料
if(mysql_num_rows($res)==0)
while($row = mysql_fetch_assoc($res))
}if($res
<> null)
echo
"返回重新";
?>
PHP實現MYSQL的查詢功能
header content type text html charset utf 8 host 127.0.0.1 port 3306 user root pass 123654 charset utf8 設定預設字元 link mysql connect host port user,pass ...
PHP開發實現快遞查詢功能詳解
背景 不久前,設計實現了京東api的功能,發現如果換了其它快遞再重新設計,豈不是會浪費太多的時間,所以選個第三方提供的快遞api是最為合理的,下面給出快遞鳥和快遞100的設計實現。1.首先要有乙個快遞鳥賬號,根據對方的要求,完善使用者申請。2.根據自己的需求,開通服務 3.進入 我的api介面 根據...
實現有道詞典功能的介面
一 不管你輸入什麼單詞,它都會呼叫網頁版的有道詞典,並且在webview中把該單詞的讀音,解釋給顯示出來。如下 1 10 11 19 20 21 22 31 32 40 41 42 43 44 mainactivity的 1 public class mainactivity extends act...