`

创建在网页的mysql表

    博客分类:
  • php
 
阅读更多

!!css!!!

table.db-table   { border-right:1px solid #ccc; border-bottom:1px solid #ccc; }
table.db-table th { background:#eee; padding:5px; border-left:1px solid #ccc; border-top:1px solid #ccc; }
table.db-table td { padding:5px; border-left:1px solid #ccc; border-top:1px solid #ccc; }

 

 

 

 

 

 

/* 链接数据库*/
$connection = mysql_connect('localhost','username','password');
mysql_select_db('my_db',$connection);

/* 输出表 */
$result = mysql_query('SHOW TABLES',$connection) or die('cannot show tables');
while($tableName = mysql_fetch_row($result)) {

  $table = $tableName[0];
 
  echo '<h3>',$table,'</h3>';
  $result2 = mysql_query('SHOW COLUMNS FROM '.$table) or die('cannot show columns from '.$table);
  if(mysql_num_rows($result2)) {
    echo '<table cellpadding="0" cellspacing="0" class="db-table">';
    echo '<tr><th>Field</th><th>Type</th><th>Null</th><th>Key</th><th>Default<th>Extra</th></tr>';
    while($row2 = mysql_fetch_row($result2)) {
      echo '<tr>';
      foreach($row2 as $key=>$value) {
        echo '<td>',$value,'</td>';
      }
      echo '</tr>';
    }
    echo '</table><br />';
  }

0
4
分享到:
评论
2 楼 qq398705749 2011-07-26  
lz12366 写道
mysql_connect,mysql_query都是jquery的方法??


不是了啦,连接mysql数据库的
1 楼 lz12366 2011-07-26  
mysql_connect,mysql_query都是jquery的方法??

相关推荐

Global site tag (gtag.js) - Google Analytics