在PHP中的HTML表中显示查询结果
16lz
2021-01-22
I need to display a table in a web page. The data from the table comes from database which I can query using mysql php library. I am looking for a template/example of how to come up with a nice looking table (I am not good at front end design).
我需要在网页中显示一个表格。表中的数据来自数据库,我可以使用mysql php库查询。我正在寻找一个模板/示例,说明如何提出一个漂亮的表(我不擅长前端设计)。
Any link/example/references will be appreciated.
任何链接/示例/参考将不胜感激。
5 个解决方案
#1
5
Here is an example on how to read a MySQL table into a HTML table. And no, it does not look nice.
以下是如何将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表格列,两个边框?
- 网站开发进阶(二十五)js如何将html表格导出为excel文件
- 100%高度分区内显示:表格单元分区
- html 防止表格或div被撑开
- 怎样把Excel表格转换成html网页格式输出?急!!
- HTML之表格篇——表格的嵌套
- 第二个表格单元格未与顶部对齐
- 对于表格数据,什么渲染更快,CSS或?
- 经典炫酷的HTML5/jQuery动画应用示例及源码