Results 1 to 3 of 3

Thread: show latest 20 referers php script

  1. #1
    Join Date
    Aug 2006
    Posts
    79
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default show latest 20 referers php script

    Does anyone know of/ have a script (perhaps php) that can show the latest X number of referers?

  2. #2
    Join Date
    Feb 2007
    Posts
    116
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I don't have/know of a script, but I can think of at least one way to do it. Use a MySQL database to keep track of referers. Every time the page is loaded, stick the referer in the database, and if the number of rows is greater than X, delete the last row.

    In php, $_SERVER['HTTP_REFERER'] will tell you the referer.
    "Rock and roll ain't noise pollution." - AC/DC

    http://www.blake-foster.com

  3. #3
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    To expand on this, set up a second column in the above said database. That column will be the "count" column.

    Simply do something like this:

    Code:
    $info = mysql_query("SELECT * FROM `$table`");
    
    while ($qry = mysql_fetch_array($info)) {
    
       if ($_SERVER['HTTP_REFERER'] == $qry['referer']) {
            $qry['count']++;
       }
    
       else {
          mysql_query("INSERT INTO `$table` (`referer`,`count`) VALUES ('$_SERVER["HTTP_REFERER"]','1')");
       }
    }
    Hope this helps.
    Last edited by thetestingsite; 02-27-2007 at 03:36 AM.

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
  •