Advertise with us

count website visitors

Posted by  marcel ethan
 1827  View(s)
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
2    1-1-2012
3    12-2-2012

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

Thanks in advance
  1. 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