我們如何編寫 PHP 指令碼來獲取 MySQL 資料庫列表?


我們可以編寫以下 PHP 指令碼來獲取可用 MySQL 資料庫的列表 −

示例

<?php
   $con = mysql_connect("localhost", "userid", "password");

   if (!$con) {
      die('Could not connect: ' . mysql_error());
   }
   $db_list = mysql_list_dbs($con);

   while ($db = mysql_fetch_object($db_list)) {
      echo $db->Database . "<br />";
   }
   mysql_close($con);
?>

更新於:2020 年 6 月 22 日

1K+ 檢視次數

開啟您的 職業生涯

透過完成課程獲得認證

開始
廣告
© . All rights reserved.