小詞典(php)

來源:互聯網
上載者:User
  • 查詢前台頁面(enword.php)

  • 英漢詞典

    2.編寫資料庫操作類(ewTool.class.php)

    conn=mysql_connect($this->host,$this->user,$this->password) or die("連結失敗");        mysql_select_db($this->bd);        mysql_query("set names utf8");    }    //查詢資料庫語句    public function dql($sql)    {        //$res為資源型        $res=mysql_query($sql,$this->conn) or die(mysql_error());        return $res;    }    //添加資料庫語句    public function dml($sql)    {        $b=mysql_query($sql,$this->conn);        if(!$b)        {            return 0;        }        else        {            if(mysql_affected_rows($this->conn))            {                return 1;            }            else            {                return 2;            }        }        }}?>

    3.編寫添加前台頁面(add.php)

    請添加英漢

    4.便面dml語句代碼。

    dml($sql);    if($res==0)    {        echo "老兄沒有你沒有寫東西吧!";    }    else if($res==1)    {        echo "恭喜添加成功!";        echo "返回";    }    else if($res==2)    {        echo "你添加有誤!";    }}else{    echo"請輸入";    echo"返回";   }?>

    以上就是php代碼啦。

    mysql操作也是至關重要的哦!

  • 建立資料庫

  • create database php_dic;

    2.建立一張表

    create table dic(

    dic_id int primary key auto_increment,

    enword varchar(20) not null default'',

    chword varchar(200) not ull default''

    )set character utf8;

    3.設定字元集

    set names utf8;

    4.設定資料庫表編碼和表編碼

    alter database php_dic character set utf8;

    alter table dic character set utf8;

    然後就可以查詢和添加啦~~

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    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.