0
我想知道如何从我的模型中调用两个数据。为了解释更加进一步,我想这样的事情发生,这是我的模型:将两个不同的sem分隔成不同的表格
function result_getGrades($studentid)
{
$sql= "
SELECT g.studentid, sb.subjectcode, s.description, g.final,sb.sem,sb.sy
FROM grades g
JOIN subjectblocking sb ON g.blockcode=sb.blockcode
JOIN subjects s ON sb.subjectcode=s.subjectcode
WHERE g.studentid='$studentid'
ORDER BY sb.sem ASC, sb.sy ASC;
";
$result = $this->db->query($sql);
$result = $result->result();
return $result;
}
和本所认为:
<div class="col-md-10">
<div class="well">
<table class="table">
<thead>
<th>Subject Code</th>
<th>Description</th>
<th>Sem</th>
<th>School Year</th>
<th>Grade</th>
</thead>
<?php foreach ($query as $row){ ?>
<tr>
<td><?php echo $row->subjectcode;?><br></td>
<td><?php echo $row->description;?><br></td>
<td><?php echo $row->sem;?><br></td>
<td><?php echo $row->sy;?><br></td>
<td><?php echo $row->final;?><br></td>
</tr>
<?php } ?>
</table>
这是怎么样子,你可以看到它是一个表,我想分开具有不同sem的表,我该怎么做?
它分开,但没有成绩,只有第一列在循环 – 2015-02-09 05:57:08
我只是记录了代码,没有测试它。这是获得你想要的另一种方法的例子。希望你能弄清楚那里的任何错误:)。 – Scopey 2015-02-09 20:34:27