首页 > 代码库 > 运用表格形式显示数据库info表的信息

运用表格形式显示数据库info表的信息

<body>

<table border="1" width="100%">

  <tr>

    <td>代号</td>

    <td>姓名</td>

    <td>性别</td>

    <td>民族</td>

    <td>生日</td>

    <td>操作</td>

  </tr>

<?php

$db =new MYSQLi("localhost","root","123","t_90052");

$sql = "select * from info";

$result =$db->query($sql);

$arr =$result->fetch_all();

foreach($arr as $v)

{

  $sex = $v[2]?"男":"女";

  eaho "<tr>

    <td>{$v[0]}</td>

    <td>{$v[1]}</td>

    <td>{$sex}</td>

    <td>{$v[3]}</td>

    <td>{$v[4]}</td>

    <td>操作</td>

  </tr>";

}

?>

</table>

</body>

运用表格形式显示数据库info表的信息