gpt4 book ai didi

html - 在 PHP 的 HTML 表中显示查询结果

转载 作者:太空宇宙 更新时间:2023-11-04 13:57:43 25 4
gpt4 key购买 nike

我需要在网页中显示一个表格。表中的数据来自数据库,我可以使用 mysql php 库查询该数据库。我正在寻找如何制作漂亮表格的模板/示例(我不擅长前端设计)。

任何链接/示例/引用将不胜感激。

最佳答案

这是一个关于如何将 MySQL 表读入 HTML 表的示例。不,它看起来不太好。

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Read values from MySQL</title>
</head>
<body>
<?
mysql_connect($db_host,$db_user,$db_pw);
mysql_select_db($db_name);
?>
<table border="1">
<tbody>
<?
$result = mysql_query("SELECT firstname, lastname FROM persons")
OR die(mysql_error());
while($row = mysql_fetch_assoc($result)) {
echo '<tr><td>' . $row['firstname'] . '</td><td>' . $row['lastname'] . '</td></tr>';
}
?>
</tbody>
</table>
</body>
</html>

关于html - 在 PHP 的 HTML 表中显示查询结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2328349/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com