有:
我想创建具有 1 行(tr)的表,例如树的标题和其他行是 cicle 数组,其中父 id = 第一行(标题);但是查询的结果建立了 cicle header1-content1 header1-contet2 (并且将是 header1-content1-content2-content3)
文件中的 PHP 代码:
$query = "SELECT cafedra.*, facultet.f_name FROM cafedra,facultet WHERE facultet_id = facultet.id";
$row = $db->select($query);
$cafedra = "";
foreach($row as $r) {
$result = "<tr class='info'>
<td colspan='5'>$r[f_name]</td>
</tr>
<tr>
<td class='span1' > $r[code] </td>
<td style='text-align:left;'> $r[c_name]</td>
<td><a id='view-$r[id]' href='/facultet/$r[id]' class='btn btn-mini btn-success'><i class='icon-desktop icon-large'></i></a></td>
<td><button id='edit-$r[id]' class='btn btn-mini btn-warning' ><i class='icon-pencil icon-large'></i></button></td>
<td><button id='delete-$r[id]' class='btn btn-mini btn-danger' ><i class='icon-trash icon-large'></i></button></td>
</tr>";
$cafedra .= $result;
}
文件中的 HTML 代码:
<br/>
<h1> </h1>
<br/><br/>
<div class="row-fluid">
<div id="facultet" class="span9 offset1">
<table class="table table-hover">
<tbody>
<?php echo $cafedra; ?>
</tbody>
</table>
</div>
</div>
需要: