davinci Posted March 12, 2006 Share Posted March 12, 2006 Is there an easy way to add clicks to my DB for links that I post that direct users off my site?So far this is what I have, but does not include any counting of any sort:[code]<?phpinclude 'library/config.php';include 'library/opendb.php';$id = (isset($_GET['id']) ? $_GET['id'] : "");if (empty($id)) {$rowsPerPage = 2;$pageNum = 1; if(isset($_GET['page'])){ $pageNum = $_GET['page'];}$offset = ($pageNum - 1) * $rowsPerPage; $query = "SELECT id, title, url, description, thumbnail, DATE_FORMAT(entry_date, '%M %D %Y') AS date, category FROM plugs ORDER BY id DESC LIMIT $offset, $rowsPerPage";$result = mysql_query($query) or die('Error, query failed');?><div class="title">Must Visit</div><p> <br><?phpwhile($row = mysql_fetch_array($result)) { ?> <table width="460" border="0" align="center" cellpadding="1" cellspacing="0"> <tr> <td><table width="100%" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td width="18%" align="center" valign="top"> <div align="center"><a href="<?=$row['url'];?>"><IMG BORDER="0" img src="media/thumbs/<?=$row['thumbnail'];?>" height="80" width="80"></a></font><font face="Arial, Helvetica, sans-serif"> </font></div></td> <td width="82%" align="center" valign="top"><div align="left"> <table width="100%" border="0" cellspacing="5" cellpadding="0"> <tr> <td><font size="2"><a href="<?=$row['url'];?>"><b><?php echo $row['title'];?></b></a><br><?php echo $row['description'];?></font></td> </tr> <tr> <td> </td> </tr> </table> </div></td> </tr> <tr> <td colspan="2" align="center" valign="top"> <div align="left"> <font size="1">Submitted On: <?php echo $row['date'];?> | xxx | Category: <?=$row['category'];?> | Clicks: 99</div></td></font> </tr> </table></td> </tr> </table>[/code] Quote Link to comment Share on other sites More sharing options...
keeB Posted March 12, 2006 Share Posted March 12, 2006 You would add a column to your database called clicks, then, make a referrer PHP file.. something like 'refer.php?to=http://www.google.com' and then, do the necessary checks. [=It seems like you're proficient enough to figure out how to do that, so if you need more help don't hesitate to post! Quote Link to comment Share on other sites More sharing options...
davinci Posted March 12, 2006 Author Share Posted March 12, 2006 [!--quoteo(post=354279:date=Mar 12 2006, 03:09 PM:name=keeB)--][div class=\'quotetop\']QUOTE(keeB @ Mar 12 2006, 03:09 PM) [snapback]354279[/snapback][/div][div class=\'quotemain\'][!--quotec--]You would add a column to your database called clicks, then, make a referrer PHP file.. something like 'refer.php?to=http://www.google.com' and then, do the necessary checks. [=It seems like you're proficient enough to figure out how to do that, so if you need more help don't hesitate to post![/quote]I'm not quite as proficient as I wish I was just yet... Mostly put together my scripts from mixing and matching from different scripts.I have this script that I came across, and I use it for trading traffic where it calculates hits in and hits out. Apparently for perm linking you just need to do go.php?j=www.site.com but it doesn't seem to work for sites that aren't already sending traffic to my site:[code]<?php/* * referers.php (c) plebian.com 1999-2004 * * go.php * Jump to a url. */if(isset($_SERVER['QUERY_STRING'])){ require_once('config.php'); if(preg_match('!^[0-9]+$!',$_SERVER['QUERY_STRING'])) { $id=&$_SERVER['QUERY_STRING']; $c=mysql_query("select id,url from TW_referers where id='{$id}'"); } elseif(!empty($_GET['j'])) { $url=addslashes($_GET['j']); $c=mysql_query("select id,url from TW_referers where url='$url' order by id desc limit 1"); } else { $c=null; } $d=mysql_fetch_object($c); if(is_object($d)) { mysql_query("update TW_referers set hitsout=hitsout+1 where id='{$d->id}'"); $url=stripslashes($d->url); if(array_key_exists($url,$jump_url_replace)) $url=$jump_url_replace[$url]; } else { $url=&$_SERVER['SERVER_NAME']; }}else{ $url=&$_SERVER['SERVER_NAME'];}header("Location: http://$url");exit;?>[/code]Also I guess I would need to add to this script to have it add clicks to my links DB, because right now its only adding to the referrers DB that is special for this go.php script.Any suggestions? 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.