php - 如何在codeigniter的td列中显示静态值
问题描述
大家好,我有一张桌子,我需要显示课程报告,所以每门课程都有一个阶段,所以我有 16 种阶段,例如:暂停、资产不完整、SME 讨论..等等。就像我有 16 种类型所以我想在 mt td 列中显示 16 种类型
<table class="table table-bordered">
<thead>
<tr><th class="center">#</th>
<th class="center"><a href="ProjectView.php?course_id=1">PHY</a></th>
<th class="center"><a href="ProjectView.php?course_id=2">CHE</a></th>
<th class="center"><a href="ProjectView.php?course_id=3">ZOO</a></th>
<th class="center"><a href="ProjectView.php?course_id=4">BOT</a></th>
<th class="center"><a href="ProjectView.php?course_id=5">MATH</a></th>
<th class="center">Total</th>
</TR>
</thead>
<tbody>
<tr>
<td>On Hold</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
</tr>
</tbody>
</table>
剩余的 td 我必须计算每门课程的数量并显示
谁能帮助我我该怎么做。
提前致谢。
解决方案
如果要将变量从控制器传递到视图,请在 $data 变量中进行。
//Controller
$this->load->model('mymodel);
$data['var1'] = "Some value";
$data['var2'] = "Some value";
$data['query'] = $this->mymodel->thefunction();
//Model = mymodel
//function = thefunction(), you have to obviously create the class and function, if you don't know how to do that, let me know
$sql = "SELECT Count(courseid) as 'statusCount'";
$query = $this->db->query($sql);
当您现在要在视图模板中显示这些变量时,请按变量的名称调用变量,而不使用“$data 部分”
//In your view
<?php
foreach($query->result() as $row) {
echo "<td>" . $row->statusCount . "</td>";
}
?>
推荐阅读
- macos - load-spark-env.sh,spark-submit:没有这样的文件或目录
- python - 使用numpy数组Python的内存错误
- r - r/ggplot:计算组内的条形图份额
- android - 手写笔输入在 Unity android 上不起作用
- javascript - 即使在重新渲染时,函数也没有收到更新的 redux 状态
- matplotlib - 在 sphinx 中使用 plot 指令时指定标题时出错
- python - 尝试将列表中仅包含一个 int 的列表转换为列表中仅包含一个 int
- reactjs - 将鼠标悬停在外部元素上时 React Leaflet change maker
- python-3.x - 我想知道使用地图的字母?
- mysql - ORDER BY 数字和字符