这与我们在学校完成的小组项目有关。我们的框架是codeigniter。
SELECT *
FROM projects, task
WHERE projects.projectname = task.projectname
上面的sql语句合并项目表和任务表,其中一个项目有很多任务。用表格显示上述sql语句的结果。此表有4列作为项目名称,客户端,任务,任务相关员工。由于项目具有许多任务项目名称和客户端在每个表记录中重复。我们想要做的只展示一次这个项目名称和客户端,并在其下显示任务。我怎样才能做到这一点? 这是我们的观看代码
<table class="table table-lg" id="Table">
<thead >
<tr class="filters">
<th ><input type="text" class="form-control" placeholder="Project" disabled></th>
<th><input type="text" class="form-control" placeholder="Client " disabled></th>
<th><input type="text" class="form-control" placeholder="Project Start On" disabled></th>
<th><input type="text" class="form-control" placeholder="End On" disabled></th>
<th><input type="text" class="form-control" placeholder="Task" disabled></th>
<th><input type="text" class="form-control" placeholder="Description" disabled></th>
<th><input type="text" class="form-control" placeholder="Commission" disabled></th>
<th><input type="text" class="form-control" placeholder="Task Start On" disabled></th>
<th><input type="text" class="form-control" placeholder="Due On" disabled></th>
<th><input type="text" class="form-control" placeholder="Start" disabled></th>
<th><input type="text" class="form-control" placeholder="Pause" disabled></th>
<th><input type="text" class="form-control" placeholder="Stop" disabled></th>
</tr>
</thead>
<tbody>
<?php
if(isset($view_data) && is_array($view_data) && count($view_data)): $i=1;
foreach ($view_data as $key => $data) {
?>
<tr class="highlight" <?php if($i%2==0){echo 'class="even"';}else{echo'class="odd"';}?>>
<td><?php echo $data['projectname']; ?></td>
<td><?php echo $data['ClientName']; ?></td>
<td><?php echo $data['datetimepicker20']; ?></td>
<td><?php echo $data['datetimepicker21']; ?></td>
<td><?php echo $data['task']; ?></td>
<td><?php echo $data['Description']; ?></td>
<td><?php echo $data['Commission']; ?></td>
<td><?php echo $data['datetimepicker21']; ?></td>
<td><?php echo $data['datetimepicker22']; ?></td>
<td><input type="checkbox" name="cb1" id="cb1" value="y" onChange="changeSoma(this, 'red')" /></td>
<td><input type="checkbox" name="cb2" id="cb2" value="y" onChange="changeSoma(this, 'green')" /></td>
<td><input type="checkbox" name="cb3" id="cb3" value="y" onChange="changeSoma(this, 'yellow')" /></td>
</tr>
<?php
$i++;
}
else:
?>
<tr>
<td colspan="7" align="center" >No Records Found..</td>
</tr>
<?php
endif;
?>
</tbody>
</table>