Feeds:
Posts
Comments

Archive for February 29th, 2008

Nah kali ini tentang script php untuk menampilkan database beserta tabel dan fieldnya untuk database MySQL .  
<html>
<head>
<title>Daftar Database, TAbel dan Field</title>
</head>
<body>
<?php
$host = “localhost”;
$userid = “username”;
$passwd = “password”;
$db = “dbname”;
$link =  mysql_connect( $host, $userid, $passwd );
if ( ! $link )
    die( “Gagal tersambung ke database” );

$db = mysql_list_dbs( $link );

while ( $db_rows = mysql_fetch_row( $db ) ) {
    print “<b>$db_rows[0]</b>n”;
    if ( !@mysql_select_db( $db_rows[0], $link ) ) {
        print “<dl><dd>Gagal tersambung -> ” . mysql_error() .“ </dl>”;
        continue;
    }
    $table = mysql_list_tables( $db_rows[0], $link );
    print “t<dl><dd>n”;
    while ( $tab_rows = mysql_fetch_row( $table ) ){
        print “t<b>$tab_rows[0]</b>n”;
        $query = mysql_query( “SELECT * from $tab_rows[0]“ );
        $num_fields = mysql_num_fields( $query );
        print “tt<dl><dd>n”;
        for ( $x=0; $x<$num_fields; $x++ ){
            print “tt<i>”;
            print mysql_field_type( $query, $x );
            print “</i> <i>”;
            print mysql_field_len( $query, $x );
            print “</i> <b>”;
            print mysql_field_name( $query, $x );
            print “</b> <i>”;
            print mysql_field_flags( $query, $x );
            print “</i><br>n”;
        }
        print “tt</d1>n”;
    }
    print “t</d1>n”;
}
mysql_close( $link );
?>
</body>
</html>
Selamat mencoba !

Read Full Post »

AJX Tools (AJX)

Read Full Post »