29, May 2012

Brain Fried, need some HELP please! - webmaster forum

 
Webdigity webmaster forums
[ Home | Help | Search | Forum's Shop | Archive | Login | Register | Webmaster Directory ]
Webdigity Webmaster Forums  >  Web Development  >  PhP
Topic: Brain Fried, need some HELP please!
« previous next »
Pages: [1] Print
Instabuck - The easy way to sell digital products online

Author Topic: Brain Fried, need some HELP please!  (Read 2015 times)
Atari ST fan
*
Posts: 8
52 credits
Members referred : 0


« on: Nov 05, 2008, 03:52:58 am »

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:

Code:
if ($adtype == 1) {
echo "<a href=\"$site_url/banner.php?id=".$id."&amp;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.

Code:
else {
echo $adtext;
}

The ads display just fine. Counts views for both types of ads using the SHOW fucntion.

Code:
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
Code:
$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.

Code:
echo "<a href=\"$site_url/banner.php?id=".$id."&amp;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!
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6691
34714 credits
Members referred : 374


It's time to use PHP5!


« Reply #1 on: Nov 05, 2008, 11:44:51 am »

I get you right that you need to count the impression of text ads?

Atari ST fan
*
Posts: 8
52 credits
Members referred : 0


« Reply #2 on: Nov 05, 2008, 01:46:07 pm »

Hello Olaf,
No. They are standard ads just in a snippet. If you take a look at the code I included you can see that my script does the following two things.

1. Tracks views and clicks of local banner ads where I input the banner link, image and so on.
2. Tracks views of affiliate code type banner ads like from Commission Junction, Link Share and the like.

I need it to be able to track the HTML snippet banner ads.

Right now it just grabs the whole affiliate code and displays the banner. It then tracks the views for the affiliate banner.

It is called using $adtext;

Since it doesn't use the banner.php code to call the SHOW function it does NOT count the clicks for these ads.

I need a way, function, class of something to call something simular to the SHOW function so it will increment the clicks as well.

Does this explain better?
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 5799
46391 credits
Members referred : 3



« Reply #3 on: Nov 05, 2008, 01:56:50 pm »

Where do you keep the html snippets? Aren't they on the database?

Trial and Error my two best teachers Cool
Join us @ facebook or twitter

Last blog : Butterfly Marketing 2.0
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6691
34714 credits
Members referred : 374


It's time to use PHP5!


« Reply #4 on: Nov 05, 2008, 02:11:09 pm »

you can count clicks two ways:

redirect the URL with a script or get clicks with javascript and a click count script

Atari ST fan
*
Posts: 8
52 credits
Members referred : 0


« Reply #5 on: Nov 05, 2008, 02:17:53 pm »

Hello Nikolas,
yes the snippets are stored in the MySQL database.

In short, I have a form to add, edit and so forth for new banners. I have a choice of either LOCAL banners where I add link, image and so on. on the same form, is a textarea for adding affiliate codes like Link Share and such.

Both are stored in the database and called from it.

The local banners are called like this.

Quote
<a href="$site_url/banner.php?id=".$id."&amp;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 calls the SHOW function which increment the clicks.

The HTML snippets is called with an echo tag, like this:

Code:
echo $adtext;

It then pulls from the database and displays on the page. It will count the views since it pulls from the database.

But unlike the local banners, it does not use the banner.php script to call thr SHOW function to increment.

I need a way to have it count the clicks on the ADTEXT banners as well... Since it doesn't use the SHOW function and basically just pulls the code from the database and displays it.
« Last Edit: Nov 05, 2008, 02:26:12 pm by DonH »
Atari ST fan
*
Posts: 8
52 credits
Members referred : 0


« Reply #6 on: Nov 05, 2008, 02:21:49 pm »

Olaf,
I don't think I am making myself clear to you. Smiley

It already counts views and clicks on local banners. It counts views for snippet banners but doesn't for clicks as it pulls the snippet from the database and displays it.

It will count the clicks if I can figure out a function, class or something to have it do something like the SHOW function to increment the clicks.
Atari ST fan
*
Posts: 8
52 credits
Members referred : 0


« Reply #7 on: Nov 05, 2008, 02:33:24 pm »

If I do this, it counts everything. Increments both views and clicks because I'm just making it do with this code as there is no separation of views and clicks. No SHOW function to separate the views from the clicks.

But maybe it will show everyone what I am trying to say and do.

Here's the code that doesn't work right for obvious reasons.

Code:
if ($adtype == 1) {
echo "<a href=\"$site_url/banner.php?id=".$id."&amp;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>";
} else {
$query = "SELECT * FROM $banners WHERE id = $id";
$result = mysql_query($query) or die(mysql_error());
$row = mysql_fetch_array($result);
$adtext = $row['adtext'];
$today = date("d m Y");
$query = "SELECT * FROM $stats WHERE date_format(ezban_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 ezban_date = '$today'";
$result = mysql_query($query) or die(mysql_error());
echo $adtext;
}
}

As you can see. IF it's a local banner it use the SHOW function. ELSE it displays the ADTEXT.
« Last Edit: Nov 05, 2008, 02:35:00 pm by DonH »
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6691
34714 credits
Members referred : 374


It's time to use PHP5!


« Reply #8 on: Nov 05, 2008, 02:46:30 pm »

maybe you should post an example snippet at this point Wink

Atari ST fan
*
Posts: 8
52 credits
Members referred : 0


« Reply #9 on: Nov 05, 2008, 02:57:49 pm »

Hello,
ok here's what a standard snippet or HTML code looks like.

Quote
<a href="http://www.domain.com" target="_blank"><img src="http://www.domain.com/banner/images/banner1.gif" border="0"><a>

As you can see, it's a standard banner tag. This is what it pulls from the database and displays it on the page.

It is called using the echo tag of $adtext;

Unlike the local banners that use a tag that also calls the SHOW function to increment the clicks... This one only displays the code.

If I use this code

Code:
if ($adtext == "$adtext") {
$query = "SELECT * FROM $banners WHERE id = $id";
$result = mysql_query($query) or die(mysql_error());
$row = mysql_fetch_array($result);
$adtext = $row['adtext'];
$today = date("d m Y");
$query = "SELECT * FROM $stats WHERE date_format(ezban_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 ezban_date = '$today'";
$result = mysql_query($query) or die(mysql_error());
}

It will increment both VIEW and CLICKS for the HTML code snippet... Which is not correct. But the idea of needing a function, class or something to trigger a process to only count clicks when it is actually clicked on...

Making more sense yet?
« Last Edit: Nov 05, 2008, 02:59:25 pm by DonH »
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6691
34714 credits
Members referred : 374


It's time to use PHP5!


« Reply #10 on: Nov 05, 2008, 03:18:38 pm »

you need some javascript/ajax code to do this (or you need to change the snippets)

check google for ajax click counter

and the views should go together with the database record call (id load record # = success increase click by one)

Atari ST fan
*
Posts: 8
52 credits
Members referred : 0


« Reply #11 on: Nov 05, 2008, 03:23:32 pm »

Any examples either way?

Javascript, ajax or how would the snippet need to be changed?
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6691
34714 credits
Members referred : 374


It's time to use PHP5!


« Reply #12 on: Nov 05, 2008, 03:26:35 pm »

Any examples either way?

Javascript, ajax or how would the snippet need to be changed?

maybe you should try the examples you can find via the google link? This is how most webmaster work Wink

Atari ST fan
*
Posts: 8
52 credits
Members referred : 0


« Reply #13 on: Nov 05, 2008, 03:48:33 pm »

Olaf, been doing that for days now. Posting here was a last resort, not my first resort.

But thank you for your time.
Trackback URI for this entry : http://www.webdigity.com/trackback.php?topic=8165
Tags : php mysql Bookmark this thread : Digg Del.icio.us Dzone more....

Pages: [1] Print 
Webdigity Webmaster Forums  >  Web Development  >  PhP
Topic: Brain Fried, need some HELP please!
« previous next »
Jump to:
User Area
Welcome, Guest. Please login or register.
Did you miss your activation email?
May 29, 2012, 12:45:34 am





Login with username, password and session length

Donate to our community, and get a permanent link back to your site!

Donate to our community, and get a permanent link back to your site!






Web Design Gallery · Whois Lookup · Pagerank · Tag Browsing · Lo-fi version · Syndication · Webmaster forum history · Advertise
Developed by HumanWorks © 2005 - 2012 Webdigity webmaster community · sublime directory
Webdigity Webmaster Forums | Powered by SMF 1.0.12. © 2001-2005, Lewis Media. All Rights Reserved.