如何編寫 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);
?>

更新日期: 22-6 月-2020

1K+ 次檢視

職業生涯起跑線

透過完成課程獲得認證

立即開始
廣告
© . All rights reserved.