SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot
    Join Date
    Aug 2000
    Washington, DC
    0 Post(s)
    0 Thread(s)
    I am trying to implement a simple click-counter so I can see how many people I am sending to sites that I have traded links with.

    I pulled all of the "friends" out of a DB an sent them to the following page:
    $fid = $id;
    $ads = mysql_query("SELECT * FROM Ads WHERE $fid=ID");
    while ($ad = mysql_fetch_array($ads)) {
    	$count = $ad["ClickCount"];
    	$URL = $ad["URL"];
    	$sql =  "UPDATE Ads SET " .
    			"ClickCount='$count' " .
    			"WHERE ID=$fid";
    	if (!mysql_query($sql)) {
    		echo("<p>Error Setting ClickCount: " .
    				mysql_error() . "</p>");
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <meta http-equiv="Refresh" content="5;url=<? echo "$URL"; ?>">
    This code works fine, but I've noticed that Hitbox doesn't register that person as being sent from my site. If Hitbox doesn't than I imagine that many others will not either.

    Is it possible to write a JS function with the PHP code in it, then call that function in onClick so that when the link is clicked it will run the PHP code without refreshing the page?

    BTW, all Friends links are opened in a new window.

    - Kurbin

    Also, does anyone know of a complete script that does something like this but keeps more detailed stats (such as clicks sent per day, etc).
    Don Lair - Earn cash back online.

  2. #2
    SitePoint Wizard TWTCommish's Avatar
    Join Date
    Aug 1999
    Pittsburgh, PA, USA
    0 Post(s)
    0 Thread(s)
    I've heard good things about "phpNewAds" - I havn't used it myself yet, though.

    As for your script - it might make a bit more sense to store each "click" as a record in a table - it'd take a heckuva lot of clicks to become large and unwieldly, and in the meantime you can use a simple COUNT(*) command in your SQL query to grab the number of results - that's a bit less risky than incrementing a variable.


Posting Permissions

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