如果要顯示mysql一個指定數(shù)據(jù)庫的表名的話方法很簡單,mysql提供了一個show tables命令,它返回的是一個數(shù)據(jù),下面來看我做的詳細實例,經(jīng)過測試完全可用
*/
$cn = mysql_connect('localhost','root','root');
mysql_select_db('test',$cn);
print_r(get_tables());-
function get_tables() //獲取所有表表名
{
$tables=array();
$r=fetch_all("show tables");
foreach($r as $v)
{
foreach($v as $v_)
{
$tables[]=$v_;
}
}
return $tables;
}
function fetch_all($sql)
{
$rs=mysql_query($sql);
$result=array();
while($rows=mysql_fetch_array($rs,mysql_assoc))
{
$result[]=$rows;
}
return $result;
}
//轉載注明來源于www.linuxidc.com保留連接地址!
?>
本文出自:億恩科技【prubsntakaful.com】
服務器租用/服務器托管中國五強!虛擬主機域名注冊頂級提供商!15年品質保障!--億恩科技[ENKJ.COM]
|