Welcome Guest, Not a member yet? Register   Sign In
Trying to count all records from database
#5

I think I am almost there with this.

I currently have the following in the database:

page_hits  |  date            |    pageid
5                |  2017-09-14   |  testing
5                |  2017-09-01   |  testing

and on the page I am wanting it to have 

pageid   |  page_hits
testing     |  10

But instead I am getting:

pageid   |  page_hits
testing     |  2

Here is  how far I have got my code to:

PHP Code:
$date = new DateTime('FIRST DAY OF 0 MONTHS');
 
   $pm  $date->format('n'); 
 
   $pmy $date->format('Y'); 
 
   $this->db->select('*, COUNT(page_hits) as page_hits');
 
   $this->db->from('analytics_page_views');
 
   $this->db->where('MONTH(date)'$pm);
 
   $this->db->where('YEAR(date)'$pmy);
 
   $this->db->group_by('pageid');
 
   $query $this->db->get();
 
   return $query->result();       

So i know that its using the page_hits as how many rows their is but not adding the values in page_hits together.
Reply


Messages In This Thread
RE: Trying to count all records from database - by doomie22 - 09-14-2017, 03:29 AM



Theme © iAndrew 2016 - Forum software by © MyBB