[eluser]Pascal Kriete[/eluser]
So what you want is a simple page hit counter? Pretty simple really. All you need is a mechanism to avoid duplicates. It's easiest to just track ip addresses.
Code:
/* Hits table has an auto-incrementing id and an ip field */
// Grab client IP
$ip = $_SERVER['REMOTE_ADDR'];
// Check for previous visits
$query = $this->db->get_where('hits', array('ip' => $ip), 1, 0);
$query = $query->row_array();
if (count($query < 1) )
{
// Never visited - add
$this->db->insert('hits', array('ip' => $ip) );
}
To display the counter, simply count all rows:
Code:
echo $this->db->count_all('hits');
Welcome to CodeIgniter.