【发布时间】:2017-08-11 14:15:18
【问题描述】:
这和我们在学校做的小组项目有关。我们的框架是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>
【问题讨论】:
-
使用表格?那是 UI 问题而不是 db 问题,所以 Html?窗口形式?移动 iO、Android?
-
请清楚..“使用表格显示结果”是什么意思?
-
@JuanCarlosOropeza 我使用 html 渲染输出。
-
@Krishnakumar 使用上述查询我从数据库中获取结果并使用表格显示这些结果
-
那你的问题是如何在 html 中显示数据集?
标签: mysql codeigniter