PHP 列出 MySQL 中所有的数据库
2013-01-14 13:59
211 查看
<?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 '<ul class="projects">'.NL; ///* USING: mysql_fetch_object() // --------------------------- while( $row = mysql_fetch_object( $result ) ): echo TB.'<li>'.$row->Database.'</li>'.NL; endwhile; //*/ /* USING: mysql_fetch_row() // ------------------------ while( $row = mysql_fetch_row( $result ) ): echo TB.'<li>'.$row[0].'</li>'.NL; endwhile; //*/ /* USING: mysql_fetch_assoc() // -------------------------- while( $row = mysql_fetch_assoc( $result ) ): echo TB.'<li>'.$row['Database'].'</li>'.NL; endwhile; //*/ echo '</ul>'.NL; // Free resources / close MySQL Connection mysql_free_result( $result ); mysql_close( $conn ); ?>
相关文章推荐
- php中mysql一条sql语句查询出所有符合条件的数据,该怎么写?
- PHP列出MySQL中所有数据库的方法
- php列出mysql数据表及字段
- PHP mysql 删除表中所有数据只保留一条
- php+mysql 查询当天的所有数据
- PHP列出MySQL中所有数据库的方法
- php获取mysql某数据表中所有字段
- mysql查询某字段出现次数大于n的所有数据信息,还有对列出前三位
- 数据中间平台(php,mysql,redis)
- PHP MySQL 查询 指定 范围 日期 时间段 数据 between 用法
- MySQL入门--登陆数据库、显示客户端的所有数据库、使用指定数据库、显示指定数据库中的所有数据表、
- php与mysql实现用户数据的增删改查
- PHP提取excel数据 - 导入MYSQL
- MySQL实现当前数据表的所有时间都增加或减少指定的时间间隔(推荐)
- PHP读取ACCESS数据到MYSQL
- PHP使用递归方式列出当前目录下所有文件的方法
- PHP判断mysql中的数据表是否存在
- PHP导入excel数据到MYSQL
- mysql 根据昨天日期获取 所有数据、本周数据、本月数据
- PHP查询MySQL大量数据的内存