close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Count Advertisement Clicks

Thread began 6/15/2022 1:32 pm by BillHobbs | Last modified 6/18/2022 10:00 am by Ray Borduin | 172 views | 4 replies |

BillHobbs

Count Advertisement Clicks

I have dynamic advertisement images that show up on a page. I also have a database table advertisementcounter with two fields adcountID and adcountAdID.

The advertisements are pulled in from the database and displayed as jpg images. I already have the images coded so that if the advertisement is clicked then it will go to the website for that advertisement. What I need is for the

What I need is to add the advertisement click to the advertisementcounter table: When the visitor clicks the advertisement it adds the adID to the advertisement counter.adcountAdID. Is it possible to do this with DataAssist?

Here is how I currently have it coded.

<form id="TopAdCounterForm">
<a href="<?php echo($rsTopAd->getColumnVal("adLink")); ?>" target="<?php echo($rsTopAd->getColumnVal("adTarget")); ?>"><img src="advertisments/<?php echo($rsTopAd->getColumnVal("adImage")); ?>" alt="<?php echo($rsTopAd->getColumnVal("adName")); ?>"/></a>
</form>

Thanks for any suggestions or examples.

Sign in to reply to this post

Ray BorduinWebAssist

Yes. Instead of linking directly to the page, link to a page on your site and pass in the id of the ad that was clicked. Then on that page you can increment the clicks column in the database before redirecting to the actual url.

Sign in to reply to this post
Did this help? Tips are appreciated...

BillHobbs

I did it the way you suggested and it works with the exception of when it redirects to the URL. It adds extra characters.

Example: https://awinninglook.com gets changed to https://&/#x2F;&#x2F;awinninglook.com

Code Below:

<?php require_once('Connections/connSiteDB.php'); ?>
<?php require_once('webassist/mysqli/rsobj.php'); ?>
<?php require_once('webassist/mysqli/queryobj.php'); ?>
<?php
$rsAdvertisment = new WA_MySQLi_RS("rsAdvertisment",$connSiteDB,1);
$rsAdvertisment->setQuery("SELECT * FROM advertisements WHERE adID = ?");
$rsAdvertisment->bindParam("i", "".(isset($_GET['adID'])?$_GET['adID']:"") ."", "-1"); //colname
$rsAdvertisment->execute();
?>
<?php $link = ($rsAdvertisment->getColumnVal("adLink")); ?>
<?php
if (!($rsAdvertisment->TotalRows === 0)) {
$InsertQuery = new WA_MySQLi_Query($connSiteDB);
$InsertQuery->Action = "insert";
$InsertQuery->Table = "advertisementcounter";
$InsertQuery->bindColumn("adcountAdID", "i", "".($rsAdvertisment->getColumnVal("adID")) ."", "WA_BLANK");
$InsertQuery->saveInSession("adcountID");
$InsertQuery->execute();
$InsertGoTo = "$link";
if (function_exists("rel2abs")) $InsertGoTo = $InsertGoTo?rel2abs($InsertGoTo,dirname(__FILE__)):"";
$InsertQuery->redirect($InsertGoTo);
}
?>
<form method="post" id="AdCounterForm" title="AddCounterForm">
<input name="adID" type="hidden" id="adID" value="<?php echo($rsAdvertisment->getColumnVal("adID")); ?>">
</form>

Sign in to reply to this post

Ray BorduinWebAssist

Use:
<?php $link = ($rsAdvertisment->getColumnVal("adLink",false)); ?>

It automatically add cross site scripting protection by encoding values from the database. Adding the false at the end tells it to not encode the characters.

Sign in to reply to this post
Did this help? Tips are appreciated...

BillHobbs

Perfect thanks.

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...