日期:2014-05-17 浏览次数:20672 次
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>顯示所有記錄</title>
</head>
<body>
<h1 align="CENTER">帳號密碼顯示表</h1>
<?php
require_once("mysql.php");
$link = create_connection();
$sql = "SELECT no AS '編號',username AS '帳號',password AS '密碼' FROM root";
$result = execute_sql("os", $sql, $link);
echo "<table border='1' align='center'><tr align='center'>";
for ($i = 0; $i < mysql_num_fields($result); $i++)
echo "<td>" . mysql_fetch_field($result, $i)->name. "</td>";
echo "</tr>";
for ($j = 0; $j < mysql_num_rows($result); $j++)
{
echo "<tr>";
for ($k = 0; $k < mysql_num_fields($result); $k++)
echo "<td>" . mysql_result($result, $j, $k) . "</td>";
echo "</tr>";
}
echo "</table>" ;
mysql_free_result($result);
mysql_close($link);
?>
</body>
</html>
<?php
function create_connection()
{
$link = mysql_connect("localhost","root","")
or die("無法連接" . mysql_error());
mysql_query("SET NAMES utf8");
return $link;
}
function execute_sql($database,$sql,$link)