<table cellspacing="0" cellpadding="0"><tr><td class="t_f" id="postmessage_66274"> <div class="blockcode"> <div id="code_iCx"><ol> <li><?php<li>define( 'NL', "n" );<li>define( 'TB', ' ' );<li>// connecting to MySQL.<li>$conn = @mysql_connect( 'localhost', 'username', 'password' )<li> or die( mysql_errno().': '.mysql_error().NL );<li>// attempt to get a list of MySQL databases<li>// already set up in my account. This is done<li>// using the PHP function: mysql_list_dbs()<li>$result = mysql_list_dbs( $conn );<li>// Output the list<li>echo '<ul class="projects">'.NL;</li> <li> <li> ///* USING: mysql_fetch_object()</li> <li> // ---------------------------</li> <li> while( $row = mysql_fetch_object( $result ) ):</li> <li> echo TB.'<li>'.$row->Database.'</li>'.NL;</li> <li> endwhile;</li> <li> //*/</li> <li> /* USING: mysql_fetch_row()</li> <li> // ------------------------</li> <li> while( $row = mysql_fetch_row( $result ) ):</li> <li> echo TB.'<li>'.$row[0].'</li>'.NL;</li> <li> endwhile;</li> <li> //*/</li> <li> /* USING: mysql_fetch_assoc()</li> <li> // --------------------------</li> <li> while( $row = mysql_fetch_assoc( $result ) ):</li> <li> echo TB.'<li>'.$row['Database'].'</li>'.NL;</li> <li> endwhile;</li> <li> //*/</li> <li>echo '</ul>'.NL;</li> <li>// Free resources / close MySQL Connection</li> <li>mysql_free_result( $result );</li> <li>mysql_close( $conn ); </li> <li>?></li> </ol></div> <em onclick="copycode($('code_iCx'));">复制代码</em> </div> <br> </td></tr></table> <div class="ptg mbm mtn"> PHP, MySQL</div> <div id="comment_66274" class="cm"> </div> <div id="post_rate_div_66274"></div> <br><br>