2 回答
TA贡献1829条经验 获得超4个赞
你有一个对象数组。每个对象都有可以引用的属性。
因此,对于数组$result,您可以遍历数组。
foreach($result as $row) {}
然而,每一行都是一个对象;对象的属性被引用如下:$row->Document_No
因此,如果您想使用字段 [Document_No] [Line_No][Description] [Type] [Quantity] 打印表格,您可以这样做:
<?php
// do whatever to get $result
// php logic finished...
?>
<table>
<tr>
<th>Document_No</th>
<th>Line_No</th>
<th>Description</th>
<th>Type</th>
<th>Quantity</th>
</tr>
<?php foreach($result as $row): ?>
<tr>
<td><?= $row->Document_No ?></td>
<td><?= $row->Line_No ?></td>
<td><?= $row->Description?></td>
<td><?= $row->Type ?></td>
<td><?= $row->Quantity ?></td>
</tr>
<?php endforeach; ?>
</table>
对于表单,同样的想法适用:
<?php foreach($result as $index => $row): ?>
<input disabled id="description" class="form-control input-group-lg reg_name" name=“description[<?= $index ?>]” value=“<?= $row->Description?>” >
...
<?php endforeach; ?>
- 2 回答
- 0 关注
- 176 浏览
添加回答
举报