Welcome Guest, Not a member yet? Register   Sign In
Help with collating database information
#6

(01-14-2017, 12:24 PM)doomie22 Wrote: Hi,

I am at a stage where i have a load of information in a database that i want to put into a webpage for people to see. 

For example i have a table that has page names that people have visited but what i want to do is say collate all of the page views of say the home page for the month. But i am really not sure how i can tell codeigniter to do this as i dont want to hard code which pages to search (as pages may change name and be added/taken away).

So what i am trying to do is say like this example

Home - 200 views
About us - 150 views 
Contact us - 100 views
Etc....

Has anyone got any ideas on how to start please?

Thanks,

Doomie

Like @PaulD said an SQL statement would probably work best, depending on how you have this saved in database.



eg. if its all in the one table..




recordID, pagename , datetime

1,homepage , 1000-01-01 00:00:00

2,homepage , 1000-01-01 00:00:00

3,about us , 1000-01-01 00:00:00 



something like this should work..

Code:
SELECT pagename, COUNT(*)
FROM tablename
WHERE datetime BETWEEN NOW() - INTERVAL 30 DAY AND NOW()
GROUP BY pagename
Reply


Messages In This Thread
RE: Help with collating database information - by mccalluma - 01-15-2017, 07:35 PM



Theme © iAndrew 2016 - Forum software by © MyBB