huangye-dream
<?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 );   
?>

  

分类:

技术点:

相关文章:

  • 2021-12-07
  • 2021-11-17
  • 2021-11-07
  • 2021-11-30
  • 2021-11-17
  • 2022-12-23
  • 2021-11-30
猜你喜欢
  • 2021-11-07
  • 2021-09-28
  • 2021-11-17
  • 2022-02-05
  • 2021-09-08
  • 2021-12-13
相关资源
相似解决方案