Rheves Posted December 12, 2007 Share Posted December 12, 2007 I want to start tracking referrers to the site, so I've set up a table with Hits, WebPage, and Referrer. Since every page includes Top.php I'd be including this at the top: $Hits = 0; $Exists = "No"; $ref=@$HTTP_REFERER; $query = "Select Hits from WebsiteTraffic where WebPage = '$HTTP_HOST$PHP_SELF' AND Referrer = '$ref' "; $result = mssql_query($query); while($row = mssql_fetch_array($result){ $Hits = $row["Hits"]; $Hits += 1; $query = "UPDATE WebsiteTraffic set Hits = '$Hits' where WebPage = '$HTTP_HOST$PHP_SELF' AND Referrer = '$ref' "; $result = mssql_query($query); $Exists = "Yes"; } if($Exists == "No"){ $query = "INSERT INTO WebsiteTraffic Values('1','$HTTP_HOST$PHP_SELF','$ref')"; mssql_query($query); } I think I've covered everything but I want to get this right from the start, does anyone have any tips or see any problem with what I have there? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.