|
<?php
@mysql_connect("localhost", "root","1981427") //選擇數(shù)據(jù)庫之前需要先連接數(shù)據(jù)庫服務(wù)器
or die("數(shù)據(jù)庫服務(wù)器連接失敗");
$dbs = mysql_list_dbs(); //調(diào)用mysql_list_dbs函數(shù)
while ($array = mysql_fetch_row($dbs)) //循環(huán)輸出所有的數(shù)據(jù)庫名稱
{
echo "$array[0]<BR>";
}
?>
復(fù)制代碼 代碼如下:
<?php
@mysql_connect("localhost", "root","1981427") //選擇數(shù)據(jù)庫之前需要先連接數(shù)據(jù)庫服務(wù)器
or die("數(shù)據(jù)庫服務(wù)器連接失敗");
$dbs = mysql_list_tables("test"); //調(diào)用mysql_list_tables函數(shù)
while ($array = mysql_fetch_row($dbs)) //循環(huán)輸出所有的表名稱
{
echo "$array[0]<BR>";
}
?>
復(fù)制代碼 代碼如下:
<?php
mysql_connect("localhost","root","1981427"); //連接服務(wù)器
mysql_select_db("test"); //選擇數(shù)據(jù)庫
$result = mysql_query("SELECT * FROM tablename1"); //執(zhí)行查詢操作
echo mysql_num_fields($result); //獲取列的數(shù)目
?>
復(fù)制代碼 代碼如下:
<?php
mysql_connect("localhost","root","1981427");
mysql_select_db("test");
$result = mysql_query("SELECT * FROM tablename1");
echo mysql_field_name($result,0); //獲取列的名稱
?>
復(fù)制代碼 代碼如下:
<?php
mysql_connect("localhost","root","1981427");
mysql_select_db("test");
$result = mysql_query("SELECT * FROM tablename1");
echo mysql_field_type($result,0); //獲取列的數(shù)據(jù)類型
?>
復(fù)制代碼 代碼如下:
<?php
mysql_connect("localhost","root","1981427");
mysql_select_db("test");
$result = mysql_query("SELECT * FROM tablename1");
echo mysql_field_len($result,0); //獲取列的長度
?>
復(fù)制代碼 代碼如下:
<?php
mysql_connect("localhost","root","1981427");
mysql_select_db("test");
$result = mysql_query("SELECT * FROM tablename1");
echo mysql_field_flag($result,0); //獲取列的標(biāo)志
?>
復(fù)制代碼 代碼如下:
<?php
mysql_connect("localhost","root","1981427"); //連接服務(wù)器
mysql_select_db("test"); //選擇數(shù)據(jù)庫
echo "<table border='1'>"; //輸出表頭
echo "<tr><th>列名</th><th>類型</th><th>長度</th><th>標(biāo)志</th>";
$result = mysql_query("SELECT * FROM tablename1"); //在mytable表上執(zhí)行SQL語句
$fields = mysql_num_fields($result); //獲得列的數(shù)目
for($i=0; $i<$fields; $i++) //循環(huán)獲得各列信息
{
//獲得列的各個屬性
$name = mysql_field_name($result,$i); //獲得列的名稱
$type = mysql_field_type($result,$i); //獲得列的類型
$length = mysql_field_len($result,$i); //獲得列的長度
$flags = mysql_field_flags($result,$i); //獲得列的標(biāo)志
echo "<tr><td>$name</td>
<td>$type</td>
<td>$length</td>
<td>$flags</td></tr>";
//輸出列的信息
}
echo "</table>";
mysql_close(); //關(guān)閉與數(shù)據(jù)庫的連接
?>
php技術(shù):php 獲取mysql數(shù)據(jù)庫信息代碼,轉(zhuǎn)載需保留來源!
鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標(biāo)記有誤,請第一時間聯(lián)系我們修改或刪除,多謝。