1
votes

I am getting comments from a database, I have a row with two columns, I am looping through the database table which contains two results, for some reason the data that is retrieve from the database is being duplicated.

comments view

<?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 } ?>

query

function get_testimonies() {
    $query = $this->db->query('SELECT comment FROM testimonies');
    return $query;
}

current result

comment 1 comment 1 comment 2 comment 2

expected result

comment 1 comment 2

1
Maybe because you are repeating this line <p class=""><?php echo $row['comment'];?></p> - Hackerman

1 Answers

1
votes

You have an echo two times, try something like:

<?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 
}
?>