Welcome Guest, Not a member yet? Register   Sign In
Some newbie Activerecords questions

Hey all,

Sorry for the newbie questions! I'm writing a controller for a 'post detail' page, that only needs to request a specific table row via ID.

Here is my controller. When I echo out $val, I get the proper response - so I assume my active records query is wrong? Or maybe I'm not calling it correctly in the view file.

I also understand I should be doing this from the model, however I'm just prototyping and learning; and right now this is the less confusing way Wink

function test($val)
    $data['test'] = $this->db->get_where('blog', array('id' => $val), 1, 0);
    $this->load->view('post_view', $data);

View - I understand this is probably wrong, I shoulnd't have to foreach a single row.
<?php foreach($test->result() as $row):?>
      <li class="block">&lt;?=$row->$post_title?&gt;</li>
&lt;?php endforeach;?&gt;

Any help would be greatly appreciated! Thanks in advance.

Hi visua,

I am also new around here so I may be wrong but, if you posted your code correctly, you should get an error
in you view file.

It should be "$row->post_title" instead of "$row->$post_title". One to many "$" signs.

I'm not a native English-speaking person so please excuse me if I made any mistakes :-P

Theme © iAndrew 2016 - Forum software by © MyBB