對於一個初學者來說,他們在學習的過程中肯定要學到靈活的運用各種
mysql_field_type()函數可獲得欄位的資料類型,該函數的文法格式如下。
string mysql_field_type ( resource $result, int $field_offset )
mysql_field_type()函數類似於函數mysql_field_name(),不過mysql_field_type()函數返回的是欄位的資料類型。它的參數的描述如下。
l result:mysql_query()函數執行後返回的結果集。
l field_offset:欄位的位移量,起始值為零。
使用mysql_field_type()函數的範例程式碼如下:
代碼23-12 光碟片codes第23章23.3mysql_field_type.php
- < ?php
- $connection=mysql_connect("localhost",
"root","root") or die("串連伺服器失敗");
- mysql_select_db("sunyang",$connection)
or die("選擇資料庫失敗");
- $query="select * from employee";
- $result=mysql_query($query) or die
("查詢資料失敗");
- //執行查詢
- echo mysql_field_type($result,0);
- //第一個欄位的資料類型
- echo "< br>";
- echo mysql_field_type($result,1);
- //第二個欄位的資料類型
- echo "< br>";
- echo mysql_field_type($result,2);
- //第三個欄位的資料類型
- mysql_free_result($result);
- mysql_close();
- ?>
上面代碼執行後將把表employee中的前3個欄位的資料類型輸出。
http://www.bkjia.com/PHPjc/445931.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/445931.htmlTechArticle對於一個初學者來說,他們在學習的過程中肯定要學到靈活的運用各種 mysql_field_type()函數可獲得欄位的資料類型,該函數的文法格式如下。...