A simple MySQL data browser_PHP tutorial

WBOY
Release: 2016-07-21 16:04:16
Original
829 people have browsed it

This program can be used to browse data in MySQL. You can make a very good MySQL browser with a few modifications.
*/

/*
?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) ;< ;br>'.chr(13);
}
mysql_free_result ($dbs); ) or die ('MySQL_LIST_TABLES error:'.
$ php_errmsg);
Echo 'Tables on'. $ db. 'of'. $ host. 🎜> $num_rows = mysql_num_rows($tables);
for($i=0;$i<$num_rows;$i++){
$table = mysql_tablename($tables,$i);
echo '                                                                                                                                                                 
'.
                                                                                                                                                                  PHP_SELF.'?cmd=db">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 '< ;tr>'.chr(13);
for($i=0;$i<$num_fields;$i++)
echo ''.chr(13);
  }
echo '
'.mysql_field_name($records,$i).'
'.$row[$i].'< /td>'.chr(13);
    echo '
'.chr(13);
mysql_free_result($records);
echo '
show databases
                                                                    a>'.chr(13);
break;
}

mysql_close($con) or die('Unable to disconnect from '.$host.');
?>



http://www.bkjia.com/PHPjc/316005.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/316005.htmlTechArticleThis program can be used to browse data in MySQL. You can make a very good MySQL with a few modifications. Browser. */ /* ?cmd=db ?cmd=tabledb={} $user = 'test'; $password = ''; if(!iss...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template