Reputation: 85
Please explain steps how to calculate page views in codeigniter.
Is there any instruction on how to do this.
by using following method:
$this->input->ip_address();
How to Write $this->input->ip_address(); in Below Controller:
Controller Page
class About extends CI_Controller {
function __construct() {
parent::__construct();
$this->load->helper('array');
$this->load->model('about_model');
}
public function index() {
$data = array(
'page_title' => 'About',
'page_name' => 'site/aboutus/about',
'about' => $this->about_model->list_all(),
);
$this->load->view('site/template', $data);
}
}
?>
Model Page:
class About_model extends CI_Model {
function __construct() {
parent::__construct();
}
public function list_all() {
return $this->db->get('about')->result_array();
}
}
Upvotes: 1
Views: 2258
Reputation: 1589
$this->input->ip_address()
to take the user's ip address in the controller$this->db->select_sum("counter")->get("views_table");
and process the result.Upvotes: 3