DWGSee plus View Browser a simple MySQL data browser

Source: Internet
Author: User
Tags urlencode
This app can be used to browse the data in MySQL, you can make a good MySQL browser with a little modification.
*/
/*
? 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 (' Cannot 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 (' unable to $host. ' Disconnect ');
?>

The above describes the DWGSee plus view browser a simple MySQL data browser, including the DWGSee plus view browser content, want to be interested in PHP tutorial friends helpful.

  • Related Article

    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.