Jump to content

Archived

This topic is now archived and is closed to further replies.

davinci

Click Counter for links in my posts

Recommended Posts

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]<?php

include '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>&nbsp<br>

<?php
while($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>&nbsp;</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]

Share this post


Link to post
Share on other sites
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!

Share this post


Link to post
Share on other sites
[!--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?

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.