[eluser]Michal1[/eluser]
Hello,
I have been trying to make a simple cms and have a little problem. Right now I am working on detail content page which is shown when somebody click on the "read whole entry" on the main page.
So basically what I want to have in this detail content page is to show just a article which has been opened.
So I have a view detail_view and inside
Code:
<?php if (isset($records)) : foreach($records as $row) : ?>
<p> <?php echo $row->content; ?> </p>
<?php endforeach ;?>
<?php else : ?>
Nothing
<?php endif; ?>
Then in site controller I have a function detail
Code:
function detail()
{
$datad = array();
$product_id = $this->uri->segment(3);
if ($query = $this->site_model->get_records())
{
$this->db->where('id',$product_id);
$datad['records'] = $query;
}
$this->load->view('detail_view', $datad);
}
So basically I want to grab a article where id is match with url 3 segment which is a id of an article.
But when my article (detail page is opened) instead of concrete article I get all article from database. And dont know why.
Anybody has any ideas?
my model looks like this:
Code:
class Site_model extends Model
{
function get_records()
{
$this->db->order_by("id", "desc");
$query = $this->db->get('data');
return $query->result();
}
}