SitePoint Sponsor |
|
User Tag List
Results 1 to 2 of 2
-
Feb 7, 2001, 07:56 #1
- Join Date
- Aug 2000
- Location
- Washington, DC
- Posts
- 103
- Mentioned
- 0 Post(s)
- Tagged
- 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:
Code:<? $fid = $id; $ads = mysql_query("SELECT * FROM Ads WHERE $fid=ID"); while ($ad = mysql_fetch_array($ads)) { $count = $ad["ClickCount"]; $URL = $ad["URL"]; } $count++; $sql = "UPDATE Ads SET " . "ClickCount='$count' " . "WHERE ID=$fid"; if (!mysql_query($sql)) { echo("<p>Error Setting ClickCount: " . mysql_error() . "</p>"); } ?> <html> <title></title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <meta http-equiv="Refresh" content="5;url=<? echo "$URL"; ?>"> </head> <body> </body> </html>
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).
-
Feb 7, 2001, 10:21 #2
- Join Date
- Aug 1999
- Location
- Pittsburgh, PA, USA
- Posts
- 3,910
- Mentioned
- 0 Post(s)
- Tagged
- 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.
Bookmarks