Hello,
Am I on the right track to create code for view counter in php?
I am using codeIgniter framework.
My code is:
Code PHP:function update_view_count($topic_id) { $count = 0; $query = "SELECT viewcount FROM forum_topics WHERE id = '".$topic_id."'"; $temp=$this->db->query($query); foreach($temp->result() as $value) { $count = $value->viewcount; } $count = $count + 1; $query="UPDATE forum_topics SET viewcount = $count WHERE id=$topic_id"; $temp = $this->db->query($query); return $count; }
or is there any other way?




Bookmarks