久久久久久久视色,久久电影免费精品,中文亚洲欧美乱码在线观看,在线免费播放AV片

<center id="vfaef"><input id="vfaef"><table id="vfaef"></table></input></center>

    <p id="vfaef"><kbd id="vfaef"></kbd></p>

    
    
    <pre id="vfaef"><u id="vfaef"></u></pre>

      <thead id="vfaef"><input id="vfaef"></input></thead>

    1. 站長資訊網(wǎng)
      最全最豐富的資訊網(wǎng)站

      php數(shù)據(jù)庫的數(shù)據(jù)表怎么弄

      php數(shù)據(jù)庫的數(shù)據(jù)表怎么弄

      數(shù)據(jù)庫是由很多張的數(shù)據(jù)表構(gòu)成的,數(shù)據(jù)庫就相當于一個房間,數(shù)據(jù)表就相當于房間里面的箱子,下面我們來看一下PHP數(shù)據(jù)庫中創(chuàng)建數(shù)據(jù)表的方法。

      推薦:php服務器

      1、輸入登陸信息

      老規(guī)矩,要想操作數(shù)據(jù)庫,就必須先連上數(shù)據(jù)庫,那么我們先要創(chuàng)建好我們要登陸的信息:

      $username="root"; $password=""; $servernmae="localhost"; $dbname="ceshi";

      2、連接數(shù)據(jù)庫

      連接數(shù)據(jù)庫很簡單,一句話就搞定了,上一篇文章里學過了,我們這里就不再累贅了,例子如下:

      $connect=new mysqli($servernmae,$username,$password,$dbname);

      只不過這里的參數(shù)多了一個$dbname,剛才我們也說了這個$dbname的意思,這個參數(shù)必須要帶上。

      3、填寫sql語句

      我們先來看一下創(chuàng)建數(shù)據(jù)表的sql語句的一個例子:

      $sql="create table test1( idint(7) unsigned not null auto_increment primary key,//主鍵 usernamevarchar(64) not null,//用戶名 ageint(3) not null,//年齡 register_timetimestamp//注冊時間 )";

      上面的test1是自定義的表名,加粗顯示的是表中的字段,字段后面緊跟的就是這個字段的類型,比如varchar(64)表示用的是字符串的類型,占64個字符,在類型后面就是限定的語句,如not null,表示不允許空值。

      CREATE TABLE 語句用于創(chuàng)建 MySQL 表。每個表都應該有一個主鍵(本列為 "id" 列),主鍵必須包含唯一的值。

      4、執(zhí)行語句。

      新建好sql語句,我們就將要大功告成了,執(zhí)行sql語句,并對執(zhí)行結(jié)果做出相應的判斷,如果有錯,給出相應的提示。

      $query=$connect->query($sql); if($query){ echo "成功創(chuàng)建數(shù)據(jù)表!"; } else{ echo $connect->error; }

      5、測試。

      開啟本地的apache和mysql服務,在瀏覽器中輸入網(wǎng)址進行訪問,結(jié)果如下:

      php數(shù)據(jù)庫的數(shù)據(jù)表怎么弄

      贊(0)
      分享到: 更多 (0)
      ?
      網(wǎng)站地圖   滬ICP備18035694號-2    滬公網(wǎng)安備31011702889846號