利用 php 列印 DB 中的 資料表 於螢幕

<?php
  $db=mysql_connect('localhost','root','password') or die('無法連上資料庫伺服器');
  mysql_select_db('test',$db) or die('無法連上資料庫');
  $sql="select * from sale;";
  $result=mysql_query($sql,$db);
  mysql_close($db);
  $no_fields=mysql_num_fields($result);

  echo "<table border=3>";
  while($x=mysql_fetch_row($result)){
     echo "<tr>";
     for($j=0;$j<$no_fields;$j++)
        echo "<td> $x[$j]</td>";
     echo "</tr>";
  }
  echo "</table>";
?>

=======================================================

mysql_list_dbs --- 列出 MySQL 伺服器上可用的資料庫

<?php
$link = mysql_connect('localhost','root','east911');
$db_list = mysql_list_dbs($link);
while ($row = mysql_fetch_object($db_list)) {
     echo $row->Database . "<BR>";
}
?>

// mysql_list_tables --- 列出資料庫中的表格
// mysql_list_tables ( string $database [, resource $link_identifier ] )

 

arrow
arrow
    全站熱搜

    annar2009 發表在 痞客邦 留言(0) 人氣()