SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Enthusiast cyberiakris's Avatar
    Join Date
    Jan 2006
    Posts
    28
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    'advanced page views stats' script

    Hello all,
    Please I need help locating a useful script or tutorial that can be used to check how many members have viewed a particular profile page. Much like the 'Who viewed my profile' that you see in most social networking sites.

    Anyone?
    Corgito ergo sum
    www.cyberiaweb.net

  2. #2
    SitePoint Wizard wheeler's Avatar
    Join Date
    Mar 2006
    Location
    Gold Coast, Australia
    Posts
    1,369
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    well its simple really:
    1. in the members database table, have a field 'viewed' or something
    2. every time the members profile is loaded in php,
    PHP Code:
    mysql_query("UPDATE members SET viewed=viewed+1 WHERE id = $id"); 
    3. when retrieving member details, just retrieve the 'viewed' column as well and display it

    theres not much use finding some non-relevant script for something so simple
    Studiotime - Time Management for Web Developers
    to-do's, messages, invoicing, reporting - 30 day free trial!
    Thomas Multimedia Web Development

  3. #3
    SitePoint Enthusiast cyberiakris's Avatar
    Join Date
    Jan 2006
    Posts
    28
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks wheeler.
    I already have that part covered.

    The script i mean should display each of the members that viewed the page. it doent really have to include how many times each of the members viewed the page, just the list of those that did arranged in desc order of last visitor to the page.
    Corgito ergo sum
    www.cyberiaweb.net

  4. #4
    SitePoint Guru
    Join Date
    Nov 2004
    Location
    Plano
    Posts
    643
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    create the following table:
    Code:
    CREATE TABLE `profile_views` (`user` INT,`viewer` INT,`timestamp` TIMESTAMP);
    CREATE UNIQUE user ON `profile_views`(`user`,`viewer`);
    when a page is viewed by someone logged in:

    Code:
    mysql_query("REPLACE INTO `profile_views` SET timestamp=NOW() WHERE `user`=$OWNER_OF_PROFILE_PAGE AND `viewer`= $VIEWER");
    to get the list:

    Code:
    mysql_query("SELECT `viewers` FROM `profile_views` WHERE `user`=$PROFILE_OWNER ORDER BY timestamp DESC LIMIT 20");
    i haven't tested it, but you should be able to get the idea.

  5. #5
    SitePoint Enthusiast cyberiakris's Avatar
    Join Date
    Jan 2006
    Posts
    28
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    @XtrEm3

    thanks for the codes. i've made some adjustments and its actually doing what i wanted.
    thanks again
    Corgito ergo sum
    www.cyberiaweb.net


Bookmarks

Posting Permissions

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