我是 PHP 和 mysql 的新手,如果这是一个新手错误,我很抱歉。
我很难从 mysql 获取数据并将其填充到 html 表中。
所以我的脚本如下:
<html>
<head>
</head>
<body>
<div class="well">
<table class="table table-striped">
<?php
$userDetail = mysql_query("SELECT * FROM uyePopup ORDER BY id LIMIT 100") or die(mysql_error());
$useridTable = "";
$userGenderTable = "";
$userMailTable = "";
while ($userRow = mysql_fetch_array($userDetail)) {
$useridTable.= '<td>' . $userRow['id'] . '</td>';
if ($userRow['gender'] == 1) {
$userRow['gender'] = 'M';
} else {
$userRow['gender'] = 'F';
}
$userGenderTable.= '<td>' . $userRow['gender'] . '</td>';
$userMailTable.= '<td>' . $userRow['email'] . '</td>';
}
// echo $userTable;
?>
<thead>
<tr>
<th>ID</th>
<th>Gender</th>
<th>E-mail</th>
</tr>
</thead>
<tbody>
<tr>
<?= $useridTable ?>
</tr>
<tr>
<?= $userGenderTable ?>
</tr>
<tr>
<?= $userMailTable ?>
</tr>
</tbody>
</table>
</div>
</body>
</html>
所以我有这样的输出:
我已经用谷歌搜索了很长时间,但似乎没有任何效果。