我从数据库获取注释,我有一行有两列,我循环遍历数据库表,其中包含两个结果,由于某种原因,从数据库中检索的数据正在重复。
评论视图
<?php foreach ($query->result_array() as $row) { ?>
<div class="row ">
<div class="large-6 columns">
<div class="callout large ">
<p class=""><?php echo $row['comment'];?></p>
</div>
</div>
<div class="large-6 columns">
<div class="callout large bluebg ">
<p class="white"><?php echo $row['comment'];?></p>
</div>
</div>
</div>
<?php } ?>
查询
function get_testimonies() {
$query = $this->db->query('SELECT comment FROM testimonies');
return $query;
}
当前结果
评论1评论1 评论2评论2
预期结果
评论1评论2
答案 0 :(得分:1)
你有两次回声,尝试类似:
<?php foreach ($query->result_array() as $row)
{
?>
<div class="row ">
<div class="large-6 columns">
<div class="callout large ">
<p class=""><?php echo $row['comment'];?></p>
</div>
</div>
</div>
<?php
}
?>