COUNT WEBSITE VISITORS

marcel ethan

Total Post:105

Points:735
Posted by  marcel ethan
 1340  View(s)
Ratings:
Rate this:
Hi every one,

In my web project i want to store website visitors

I have a table to store website visitor count bellow

id   date          ip           
-----------------------------
1    1-1-2012     195.165.1.2
2    1-1-2012     195.165.1.3
3    12-2-2012    195.165.1.8

and i want a sql query for get count of each month of current year.

Thanks in advance
  1. AVADHESH PATEL

    Post:604

    Points:4228
    Re: count website visitors

    Hi Marcel Ethan

    You can use below sql query for getting IP information


    SELECT  MONTHNAME(STR_TO_DATE(date, '%c-%e-%Y')) `monthName`, COUNT(*) totalCount
    FROM    tableName
    WHERE   YEAR(STR_TO_DATE(date, '%c-%e-%Y')) = YEAR(CURDATE())
    GROUP BY  MONTHNAME(STR_TO_DATE(date, '%c-%e-%Y'))

    you can use another query

    "select month(date),count(distinct ip) from visitors where date>='$y-01-01' and date<'$y-12-31' group by 1"

    I hope it resolve your problem

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!