Welcome Guest, Not a member yet? Register   Sign In
Easy Question - Comments_View and Showing Article
#11

[eluser]gtech[/eluser]
well you can search the php manual on looping around the keys.

Code:
<?php
function test_print($item2, $key)
{
    echo "$key = $item2";
}
echo "<h3>";
array_walk($query, 'test_print');
echo "</h3>";
?&gt;
but the method you suggested is a perfectly valid way. it enables you to position your data where you want.
#12

[eluser]Kesey[/eluser]
Thanks all. I realize this is not CI specific stuff I'm questioning - so thanks for the quick help. Exactly what I was looking for.
#13

[eluser]gtech[/eluser]
or

Code:
<h3>
&lt;?php
foreach ($query as $value) {
  echo $value;
}
?&gt;
</h3>
#14

[eluser]Pascal Kriete[/eluser]
You can change the controller a little:
Code:
function comments($id)
{
    $query = $this->db->get_where('entries', array('id' => $id), 1, 0);
    $query = $query->row_array();

    foreach($query as $key => $field)
    {
        $data[$key] = $field;
    }

    $this->load->view('whatever', $data);
}

/* View */
<h1>&lt;?=$name?&gt;</h1>

<p>&lt;?=$body?&gt;</p>
//..etc




Theme © iAndrew 2016 - Forum software by © MyBB