120 users online (2 members and 118 guests)  

  Results 1 to 2 of 2


  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

    Join Date
    Jan 2005

    Question How can count visits?

    I’m having table visits:
    | date | ip |
    | 2005-01-24 15:03:05 | |
    | 2005-01-24 15:15:05 | |
    | 2005-01-24 15:45:05 | |
    | 2005-01-24 15:03:15 | |
    | 2005-01-24 15:33:05 | |
    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

    Join Date
    Oct 2000
    Bournemouth, UK

    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

    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