我是网页设计的新手。我已经使用 PHP 从 MySQL 数据库中访问了数据。数据显示为列表或与表格相同,我需要知道如何格式化该数据以填充我网页中的文本字段。
它是由 JavaScript 完成的吗?
使用的代码:
<html>
<head>
<title>Retrieve data from database </title>
</head>
<body>
<?php
// Connect to database server
mysql_connect("mysql.myhost.com", "user", "sesame") or die (mysql_error ());
// Select database
mysql_select_db("mydatabase") or die(mysql_error());
// SQL query
$strSQL = "SELECT * FROM people";
// Execute the query (the recordset $rs contains the result)
$rs = mysql_query($strSQL);
// Loop the recordset $rs
// Each row will be made into an array ($row) using mysql_fetch_array
while($row = mysql_fetch_array($rs)) {
// Write the value of the column FirstName (which is now in the array $row)
echo $row['FirstName'] . "<br />";
}
// Close the database connection
mysql_close();
?>
</body>
</html>