I have been working on this matter for about a week now and driving myself so nuts that now I can not even think right.
Here’s the problem.
I have a banner script which is used to display banners on my pages. It pulls from MySQL database and works fine.
The part that works fine is this:
if ($adtype == 1) {
echo "<a href="$site_url/banner.php?id=".$id."&action=show" target="$target_text" onFocus="this.blur()"><img border="$border" style="border-color: $border_color" src="$site_url/$image" title="$alt" alt="$alt"></a>";
}
This part displays local banners and counts the views and clicks just fine.
This part displays the HTML snips like affiliate codes and such which are complete tags from elsewhere.
else {
echo $adtext;
}
The ads display just fine. Counts views for both types of ads using the SHOW fucntion.
if ($action == "show") {
$query = "SELECT * FROM $banners WHERE id = $id";
$result = mysql_query($query) or die(mysql_error());
$row = mysql_fetch_array($result);
$link = $row['link'];
if (strtolower(substr($link,0,5)) != "http:")
$link = "http://" . $link;
$today = date("d m Y");
$query = "SELECT * FROM $stats WHERE date_format(banner_date, '%d %m %Y') = '$today' AND id = $id";
$result = mysql_query($query) or die(mysql_error());
$num_results = mysql_num_rows($result);
$today = date("Y-m-d");
$query = "UPDATE $stats SET clicks = clicks + 1 WHERE id = $id AND banner_date = '$today'";
$result = mysql_query($query) or die(mysql_error());
header("Location: ".$link);
}
What I need is to count the CLICKS for the HTML snip codes.
The $adtext;
displays the ads fine pulling from the database but will NOT count the clicks. I know it is
because I can not call the SHOW function to increase the clicks like I do with local banners.
While going crazy I tried this to insure I am in the right place.
echo "<a href="$site_url/banner.php?id=".$id."&action=show" target="$target_text" onFocus="this.blur()">1";
echo $adtext;
echo "</a>";
Which is NOT correct I know… BUT if I click on the number 1 displayed with this code it increments the clicks by one.
Mainly because I am calling the SHOW function.
I need a way to either call the SHOW function for the ads that are pulled and displayed using $adtext
or another function that can be used to do the same thing to count clicks.
Any help on this matter would be greatly appreciated! I also hope I am making sense here… Like I said, my brain is gone!