美文网首页
数据库渲染表格

数据库渲染表格

作者: 咸鱼前端 | 来源:发表于2019-05-22 23:01 被阅读0次
<?php
include "index.html";
header("content-type:text/html, charset=utf8");
$host = 'localhost';
$user = 'root';
$pass = 'root';
$link = mysqli_connect($host, $user, $pass, "test");
mysqli_query($link, "set names 'utf8'");
$sql = "SELECT * FROM lzq_user";
$result = mysqli_query($link, $sql);
echo "<div class='layui-container'><div class='layui-row'><table class='layui-table'><colgroup><col width='150'><col width='200'><col></colgroup><thead><tr><th>用户id</th><th>用户昵称</th><th>工作</th><th>工资</th><th>爱好</th></tr></thead><tbody>";
while ($row = mysqli_fetch_array($result)) {
    echo "<tr>";
    echo "<td>" . $row['id'] . "</td>";
    echo "<td>" . $row['username'] . "</td>";
    echo "<td>" . $row['job'] . "</td>";
    echo "<td>" . $row['money'] . "</td>";
    echo "<td>" . $row['hobby'] . "</td>";
    echo "</tr>";
}
echo "</tbody>";
echo "</table>";
echo "</div>";
echo "</div>";

相关文章

网友评论

      本文标题:数据库渲染表格

      本文链接:https://www.haomeiwen.com/subject/ybzpzqtx.html