39 users online (0 members and 39 guests)  


  Results 1 to 2 of 2

Related

  1. Count and rows code    Forum: PHP Forum
    Replies: 0
  2. see who visits my myspace?    Forum: Myspace Forum
    Replies: 7
  3. how to count clicks/guesses?    Forum: Javascript Forum
    Replies: 3
  1. #1
    ramis55's Avatar
    New User

    Status
    Offline
    Join Date
    Jan 2005
    Posts
    8

    Question How can count visits?

    Hello
    I’m having table visits:
    | date | ip |
    | 2005-01-24 15:03:05 | 0.0.0.1 |
    | 2005-01-24 15:15:05 | 0.0.0.1 |
    | 2005-01-24 15:45:05 | 0.0.0.1 |
    | 2005-01-24 15:03:15 | 0.0.0.2 |
    | 2005-01-24 15:33:05 | 0.0.0.2 |
    I want count how the visits were made. A timeout period of new visit is 30 minutes.

    Result will be:
    | date | visits |
    | 2005-01 | 2 |

  2. #2
    QuietDean's Avatar
    Administrator

    Status
    Offline
    Join Date
    Oct 2000
    Location
    Bournemouth, UK
    Posts
    2,662
    Hi,

    Just to make sure I understand you, you already have the visits table, and its been recording data. You just want to know how to make a meaningful report?

    The simple way is

    Code:
    SELECT * FROM visits ORDER BY ip
    This will then show all visitors, and you can tell by looking what times, dates etc. This will not filter your "new visit" 30 minutes cut-off though.

    To make this more meaningful, its going to get complicated.

    We will assume a day at first. If you want a report spanning more days, you can add a loop afterwards that loops thru a range of days.

    lets say 2005-01-01

    it selects all results for 2005-01-01, order by time.

    You then go through each result. Take the timestamp, take the IP. Add it to an array with a third value in the array of 1 (visits)

    For the next result, compare the IP. Is it the same? If it is, then check the time. If the time is more than 30 minutes later, add +1 to the (visits) value of the array for that IP. If less than 30 minutes, then ignore and move on to the next.

    Now, once this process finishes, if you then print out the array, you will have your data above in the format you wanted.

    I was going to actually provide code, but its pretty complicated and I think you will be better off creating the actual nuts and bolts yourself. That way, you will get it exactly the way you want it.
    If one of our members helps you, please click the icon to add to their reputation!
    No support via email or private message - use the forums!
    Before you ask, have you Searched?



Tags for this Thread