我得到的结果有问题,我尝试从我的数据库中获取数据,我想让所有数据都是动态的,所以对于“header”表我必须从数据库中获取它,而对于“body”我想要从数据库中获取它也取决于“header_id”。得到的“body”的结果应该是从左到右,而不是从上到下。
你可以看到我的结果是这样的
但这应该是这样的
有人能帮我吗?这是我的视图代码。
<table class="table table-striped table-bordered zero-configuration">
<thead>
<tr>
<?php
foreach ($du_head as $key => $value) {
echo "<th>".$value->duh_judul."</th>";
}
?>
th>Aksi</th>
</tr>
</thead>
<tbody>
<?php foreach ($du_head as $key => $value) { ?>
<tr>
<?php
$q = $this->db->query("select * from data_umum where duh_id = '$value->duh_id'")->result();
foreach ($q as $ac) {
echo "<td>".$ac->duh_isi."</td>";
echo "<td><i class='fa fa-trash'><a href=''></a></i></td>";
}
?>
</tr>
<?php } ?>
</tbody>
</table>
这是我的数组结果 du_head
array(3) {
[0]=>
object(stdClass)#38 (3) {
["duh_id"]=>
string(1) "2"
["maplink_id"]=>
string(1) "9"
["duh_judul"]=>
string(10) "Nama Jalan"
}
[1]=>
object(stdClass)#39 (3) {
["duh_id"]=>
string(1) "3"
["maplink_id"]=>
string(1) "9"
["duh_judul"]=>
string(13) "Panjang Jalan"
}
[2]=>
object(stdClass)#40 (3) {
["duh_id"]=>
string(1) "4"
["maplink_id"]=>
string(1) "9"
["duh_judul"]=>
string(5) "Lebar"
}
}
12345678_0001
森栏