有人可以帮助我将PHP表拆分为较小的可折叠表吗?
我目前正在运行此查询,以从数据库中获取结果:
$querytasks =
"SELECT *
FROM tasks
INNER JOIN usercontract on usercontract.Contract = tasks.contract
INNER JOIN users on users.ID = usercontract.UserID
WHERE (users.Username='$Username' AND users.ID = usercontract.UserID)
ORDER BY status, tasks.contract DESC, itemgroup DESC, item DESC";
$statement2 = $dbh->prepare($querytasks);
$statement2->execute();
$tasks = $statement2->fetchAll();
$statement2->closeCursor();
然后我使用一个foreach循环为该查询的每个结果在表中创建一行:
<table id="mytable" class="fixed_header">
<thead class="tbl-header" style="background-color: #007BFF;">
<tr >
<th>Contract</th>
<th>Task Group</th>
<th>Task Description</th>
<th>Assigned By</th>
<th>Assigned To</th>
<th>Status</th>
<th>Due Date</th>
<th>ID</th>
<th>Edit</th>
</tr>
</thead>
<tbody class="tbl-content">
<?php foreach ($tasks as $task) : ?>
<tr style="display: none;">
<td><?php echo $task['contract']; ?></td>
<td><?php echo $task['itemgroup']; ?></td>
<td><?php echo $task['item']; ?></td>
<td><?php echo $task['assignedby']; ?></td>
<td><?php echo $task['assignedto']; ?></td>
<td><?php echo $task['status']; ?></td>
<td><?php echo $task['due']; ?></td>
<td><?php echo $task['id']; ?></td>
<td><a class="btn btn-info edit" aria-label="Settings" onclick="updateTask('<?php echo $task['contract']; ?>','<?php echo $task['itemgroup']; ?>','<?php echo $task['item']; ?>','<?php echo $task['assignedby']; ?>','<?php echo $task['assignedto']; ?>','<?php echo $task['status']; ?>','<?php echo $task['due']; ?>','<?php echo $task['id']; ?>')">
<i class="fa fa-pencil-square-o" aria-hidden="true" ></i>
</a> </td>
</tr>
</tbody> <?php endforeach; ?>
</table>
我的表当前如下所示:
我希望它看起来像这样:
“登机点:Chanda Nagar”将改为“任务组:预警通知”,而“登机点kphb”将是“任务组:一般通信”
我相信可以使用JavaScript或jQuery完成。