This program can be used to browse MySQL data. you can make some modifications to make a good MySQL browser .*//*? Analytic DB? Cmdtabledb {}? Cmdrecorddb {} table {} */$ hostlocalhost; $ usertest; $ password; if (! Isset ($ cmd) $ MongoDB; switch ($ cmd this program can be used to browse MySQL data. you can make some modifications to make a good MySQL browser.
*/
/*
? Cmd = db
? Cmd = table & db = {}
? Cmd = record & db ={}& table = {}
*/
$ Host = 'localhost ';
$ User = 'test ';
$ Password = '';
If (! Isset ($ cmd) $ cmd = 'DB ';
Switch ($ cmd ){
Case 'DB ':
Break;
Case 'table ':
Break;
Case 'record ':
Break;
Default:
$ Cmd = 'DB ';
Break;
}
$ Con = @ mysql_connect ($ host, $ user, $ password) or die ('unable to connect '. $ host );
Switch ($ cmd ){
Case 'DB ':
$ Dbs = mysql_list_dbs ($ con) or die ('MySQL _ list_dbs error: '. $ php_errmsg );
Echo 'databases on '. $ host .':
'. Chr (13 );
$ Num_rows = mysql_num_rows ($ dbs );
For ($ I = 0; $ I <$ num_rows; $ I ){
$ Db = mysql_tablename ($ dbs, $ I );
Echo 'urlencode ($ db). '">'. $ db .'
'. Chr (13 );
}
Mysql_free_result ($ dbs );
Break;
Case 'table ':
$ Tables = @ mysql_list_tables ($ db, $ con) or die ('MySQL _ list_tables error :'.
$ Php_errmsg );
Echo 'Tables on '. $ db.' of '. $ host .':
'. Chr (13 );
$ Num_rows = mysql_num_rows ($ tables );
For ($ I = 0; $ I <$ num_rows; $ I ){
$ Table = mysql_tablename ($ tables, $ I );
Echo 'urlencode ($ db). '& table ='. urlencode ($ table). '">'. $ table .'
'.
Chr (13 );
}
Mysql_free_result ($ tables );
Echo 'show databases'. chr (13 );
Break;
Case 'record ':
$ Records = mysql_db_query ($ db, 'select * from'. $ table, $ con) or
Die ('MySQL _ db_query error: '. $ php_errmsg );
Echo 'records on '. $ table .':
'. Chr (13 );
Echo'
'. Chr (13 );Echo'
'. Chr (13 );$ Num_fields = mysql_num_fields ($ records );For ($ I = 0; $ I <$ num_fields; $ I)Echo'
'. Mysql_field_name ($ records, $ I ).' | '. Chr (13 );Echo'
'. Chr (13 );While ($ row = mysql_fetch_row ($ records )){Echo'
'. Chr (13 );For ($ I = 0; $ I <$ num_fields; $ I)Echo'
'. $ Row [$ I].' | '. Chr (13 );Echo'
'. Chr (13 );}Echo'
'. Chr (13 );
Mysql_free_result ($ records );
Echo 'show databases
Show tables
'. Chr (13 );
Break;
}
Mysql_close ($ con) or die ('cannot be disconnected from'. $ host ');
?>