沒這么干過 mysql_list_tables 獲取 所有表信息 返回指針 mysql_tablename 獲取表名
站在用戶的角度思考問題,與客戶深入溝通,找到鷹潭網(wǎng)站設(shè)計與鷹潭網(wǎng)站推廣的解決方案,憑借多年的經(jīng)驗,讓設(shè)計與互聯(lián)網(wǎng)技術(shù)結(jié)合,創(chuàng)造個性化、用戶體驗好的作品,建站類型包括:網(wǎng)站設(shè)計、做網(wǎng)站、企業(yè)官網(wǎng)、英文網(wǎng)站、手機端網(wǎng)站、網(wǎng)站推廣、域名與空間、網(wǎng)站空間、企業(yè)郵箱。業(yè)務(wù)覆蓋鷹潭地區(qū)。
myslq_num_rows函數(shù)來判斷結(jié)果指針中的表的數(shù)目
?php
mysql_connect("localhost", "mysql_user", "mysql_password");
$result = mysql_list_tables("mydb");
for ($i = 0; $i mysql_num_rows($result); $i++)
printf ("Table: %s\n", mysql_tablename($result, $i));
mysql_free_result($result);
? 這是手冊上例子 后邊的不用我說了吧 sql查詢
?php
$servername?=?"localhost";
$username?=?"root";
$password?=?"password";//mysql密碼
$dbname?=?"myDB";//選擇數(shù)據(jù)庫
//?創(chuàng)建連接
$conn?=?new?mysqli($servername,?$username,?$password,?$dbname);
//?檢測連接
if?($conn-connect_error)?{
die("Connection?failed:?"?.?$conn-connect_error);
}?
$sql?=?"SELECT?id,?firstname,?lastname?FROM?MyGuests";//sql查詢語句
$result?=?$conn-query($sql);//獲得查詢結(jié)果
if?($result-num_rows??0)?{
//?輸出每行數(shù)據(jù)
while($row?=?$result-fetch_assoc())?{
echo?"br?id:?".?$row["id"].?"?-?Name:?".?$row["firstname"].?"?"?.?$row["lastname"];
}
}?else?{
echo?"0?results";
}
$conn-close();
?
獲取ppq數(shù)據(jù)庫的所有表名的代碼:
?php
$server='localhost';
$user='root';
$pass='12345';
$dbname='ppq';
$conn=mysql_connect($server,$user,$pass);
if(!$conn)
die("數(shù)據(jù)庫系統(tǒng)連接失敗!");
$result=mysql_list_tables($dbname);
if(!$result)
die("數(shù)據(jù)庫連接失敗!");
while($row=mysql_fetch_row($result))
{
echo
$row[0]."
";
}
mysql_free_result($result);
?
mysql_list_tables
(PHP
3,
PHP
4
,
PHP
5)
mysql_list_tables
--
列出
MySQL
數(shù)據(jù)庫中的表
說明
resource
mysql_list_tables
(
string
database
[,
resource
link_identifier])
mysql_list_tables()
接受一個數(shù)據(jù)庫名并返回和
mysql_query()
函數(shù)很相似的一個結(jié)果指針。用
mysql_fetch_array()或者用mysql_fetch_row()來獲得一個數(shù)組,數(shù)組的第0列就是數(shù)組名,當獲取不到時
mysql_fetch_array()或者用mysql_fetch_row()返回
FALSE。
分享文章:php獲取數(shù)據(jù)庫表格數(shù)據(jù) php讀取數(shù)據(jù)庫內(nèi)容
地址分享:http://chinadenli.net/article8/dogsoip.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供靜態(tài)網(wǎng)站、全網(wǎng)營銷推廣、、網(wǎng)站排名、品牌網(wǎng)站設(shè)計、品牌網(wǎng)站制作
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)