Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 7 of 7
  1. #1
    Senior Member Stylise's Avatar
    Join Date
    Jul 2005
    Location
    Mount Martha, Australia
    Posts
    229
    Member #
    10679
    Hi, I was wondering how I'd go about displaying the newest x from last visit. Ie. number of new members since last visit.

    At the moment I can check who is online, as I have sessions set up that checks the status of a user, and logs it into the database, with their activity time, but I'm not sure where to go from here.

    Any help appreciated

  2.  

  3. #2
    Senior Member
    Join Date
    May 2003
    Location
    UK
    Posts
    2,354
    Member #
    1326
    Well, if you want to inform the user of the newest members then they will need to be a member themselves.

    You will also have to add a column to the users database table, such as last_login.

    This will be a timestamp (so that whenever it is updated the time will be re-entered into the users table).

    Then, on whatever page you want to notify the current user of newest users, your query would be like:

    PHP Code:
    <?php
    $query 
    "SELECT * FROM users_table WHERE last_login > $currentuserstimestamp"
    And before that (such as when you log on, instead of just setting the session variable, you would set $currentuserstimestamp to their value of the column last_login.

    Hope this helps.

  4. #3
    Senior Member rosland's Avatar
    Join Date
    Jul 2003
    Location
    Norway
    Posts
    1,944
    Member #
    2096
    In short;

    All new members will be addedto the "members database" with an auto-increment number (id).

    When a user logs in, have a function that extract the highest/last id number from the "member" database.

    If you store the session data, then you can easily retrieve the "highest-member-id-available-when-last-visiting" from your session database, and ask the script to list all new entries (higher numbers) from this variable.
    S. Rosland

  5. #4
    Senior Member Stylise's Avatar
    Join Date
    Jul 2005
    Location
    Mount Martha, Australia
    Posts
    229
    Member #
    10679
    Thanks guys, now why didn't I think of that :P

    So what I do is; when a user logs in, I register a activity session, that will update their activity time. Then I grab that time and use something like the query bfsog posted, to see what is new...

    I like it

    Although, how would I do something similiar, but something that is dependant upon the user "reading" something to mark it as "old".

    ie. the typical fourm, when a user has read a post, it will appear as read.

  6. #5
    Senior Member
    Join Date
    Jun 2005
    Location
    Atlanta, GA
    Posts
    4,146
    Member #
    10263
    Liked
    1 times
    You could always have a look at how phpBB does it, since it's open source. That might take a while, but you might learn a lot of other neat things along the way :-).

    However, I think it probably relies on a list of either fora or thread ids that you have read. If something was posted before the time you registered, it's automatically considered read. If it's after the time you registered, then when you read it appends, say, `,###' to a field called, say, `read' (where ### is the id of the thread). If you mark an entire forum read, it goes through the threads that are marked as new for you and marks them read as above. Then, when it reconstructs the forum, it checks whether the ids are in the `read' field. If they are, then it's marked as read; if they're not, it's marked unread.

    Not sure if that's how it's done, nor even if it is particularly efficient.

  7. #6
    WDF Staff Wired's Avatar
    Join Date
    Apr 2003
    Posts
    7,657
    Member #
    1234
    Liked
    137 times
    ::tutorial::
    The Rules
    Was another WDF member's post helpful? Click the like button below the post.

    Admin at houseofhelp.com

  8. #7
    Senior Member
    Join Date
    Jun 2005
    Location
    Atlanta, GA
    Posts
    4,146
    Member #
    10263
    Liked
    1 times
    Heh, that does scream tutorial doesn't it... I might just tackle that at some point...


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Search tags for this page

display time since last visit in php

Click on a term to search for related topics.
All times are GMT -6. The time now is 09:24 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com