I need little Active record help. I am trying to update page views which i store in database. Each time post() function runs, add +1 . Here is my code:
public function post($id) {
if($id == NULL){
redirect('blog');
}
else{
$this->db->where('entry_id',$id);
$this->db->set('views','views+1');
$this->db->update('entry');
Please help!
Correct your code like this for example:
Mark the
header('Location: /blog')– you should put here your real server path to the blog.If you use a custom redirection function, like your
redirect()then check if the is an output before calling her. Header redirection only works if no other output is sent to the browser before invoking it.