【发布时间】:2017-07-11 05:57:13
【问题描述】:
我在 MySql 表中有一个包含多行记录的表(existingbankproducts 表):
我用来选择的代码来自数据库如下:
$stmt2 = $DB_con->prepare("SELECT * FROM applicantpersonaldetails apd "
. "INNER JOIN existingbankproducts ext ON apd.ApplicantID = ext.ApplicantID "
. "WHERE apd.AccountID ='{$accountId}' AND apd.applicantType ='main';");
$stmt2->execute();
if ($stmt2->rowCount() > 0) {
while ($row = $stmt2->fetch(PDO::FETCH_ASSOC)) {
?>
<?php
}
} else {
?>
<div class="">
<div class="alert alert-warning">
<span class="glyphicon glyphicon-info-sign"></span> No Data Found ...
</div>
</div>
<?php
}
我想选择它们并插入到我的 HTML 表格中,代码如下:
<table>
<tr>
<th>Financial Institution</th>
<th>Product Type</th>
<th>Balance</th>
<th>Monthly Commitment</th>
</tr>
<tr>
<td><input type = "text" name = "finanIns1" id = "finanIns1" value = ""readonly></td>
<td>
<input list = "proTypeList" name = "proType1" id = "proType1"readonly >
</td>
<td id = "balance"><input type = "number" name = "balance1" id = "balance1" value = "" min = "0"readonly></td>
<td id = "MonthyComm"><input type = "number" name = "monthlyComm1" id = "monthlyComm1" value = "" min = "0"readonly></td>
</tr>
<tr>
<td><input type = "text" name = "finanIns2" id = "finanIns2" value = ""readonly></td>
<td>
<input list = "proTypeList" name = "proType2" id = "proType2" readonly>
</td>
<td id = "balance"><input type = "number" name = "balance2" id = "balance2" value = "" min = "0"readonly></td>
<td id = "MonthyComm"><input type = "number" name = "monthlyComm2" id = "monthlyComm2" value = "" min = "0"readonly></td>
</tr>
</table>
其实还有更多的行,这是一个例子。
另外,我以value="<?php echo $row['Financialinstitution'] " ?> 为例,但是,所有的记录都出来了。
有没有办法按照HTML表格的顺序显示结果。
【问题讨论】:
-
尽量只提供最短的所需代码,而不是 ctrl+a & ctrl+v。
-
在您的选择查询中使用 order by 子句,以获取排序后的输出并对其进行循环。
标签: php html mysql sql database