A simple php-implemented MySQL data browser _ PHP Tutorial

Source: Internet
Author: User
A simple MySQL data browser implemented by php. This program can be used to browse MySQL data. you can make some modifications to make a good MySQL browser .**? Analytic DB? Cmdtabledb {} nbsp; localhost; $ usertest; $ passwo 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' '. Chr (13 );Echo' '. Chr (13 );While ($ row = mysql_fetch_row ($ records )){Echo' '. Chr (13 );For ($ I = 0; $ I <$ num_fields; $ I ++)Echo' '. Chr (13 );Echo' '. Chr (13 );}Echo'
'. Mysql_field_name ($ records, $ I ).'
'. $ Row [$ I].'
'. Chr (13 );
Mysql_free_result ($ records );
Echo 'show databases
Show tables
'. Chr (13 );
Break;
}
Mysql_close ($ con) or die ('cannot be disconnected from'. $ host ');
?>

Response .*//*? Cmd = db? Cmd = tabledb ={} nbsp; = 'localhost'; $ user = 'test'; $ passwo...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.