View Full Version : show latest 20 referers php script

02-23-2007, 02:01 AM
Does anyone know of/ have a script (perhaps php) that can show the latest X number of referers?

02-25-2007, 12:30 AM
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.

02-25-2007, 12:41 AM
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:

$info = mysql_query("SELECT * FROM `$table`");

while ($qry = mysql_fetch_array($info)) {

if ($_SERVER['HTTP_REFERER'] == $qry['referer']) {

else {
mysql_query("INSERT INTO `$table` (`referer`,`count`) VALUES ('$_SERVER["HTTP_REFERER"]','1')");

Hope this helps.