本文实例讲述了PHP列出MysqL中所有数据库的方法。分享给大家供大家参考。具体如下:
PHP;">
PHP
define( 'NL',"\n" );
define( 'TB',' ' );
// connecting to MysqL.
$conn = @MysqL_connect( 'localhost','username','password' )
or die( MysqL_errno().': '.MysqL_error().NL );
// attempt to get a list of MysqL databases
// already set up in my account. This is done
// using the PHP function: MysqL_list_dbs()
$result = MysqL_list_dbs( $conn );
// Output the list
echo '
- MysqL_fetch_object()
// ---------------------------
while( $row = MysqL_fetch_object( $result ) ):
echo TB.'
- '.$row->Database.' '.NL; endwhile; //*/ /* USING: MysqL_fetch_row() // ------------------------ while( $row = MysqL_fetch_row( $result ) ): echo TB.'
- '.$row[0].' '.NL; endwhile; //*/ /* USING: MysqL_fetch_assoc() // -------------------------- while( $row = MysqL_fetch_assoc( $result ) ): echo TB.'
- '.$row['Database'].' '.NL; endwhile; //*/ echo '
希望本文所述对大家的PHP程序设计有所帮助。
原文链接:https://www.f2er.com/php/22472.html