close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Click counter on dynamic images

Thread began 1/03/2015 3:02 am by info4753 | Last modified 1/13/2015 6:12 am by Jason Byrnes | 1206 views | 3 replies |

info4753

Click counter on dynamic images

I want to count the clicks that users do on images on my homepage. The images come out of a database table and the count should happen on the homepage itself. I managed to implement an update behavior but it updates all click within the click count field of the first recordset in the database.

So the form knows that an image has been clicked but not which one. The values for the corresponding key seems to be wrong. I'm currently using <?php echo $row_rsPromotionen['PROMID']; ?> means the value from the repeated recordset of the images. But it looks like that it's not working like this.

Repeated form:

<form method="post" name="FormPromotions" >
<?php do { ?>
<div class="container-promotion"> <a href="<?php echo $row_rsPromotionen['LinkToURL']; ?>"><input type="image" name="<?php echo $row_rsPromotionen['PROMID']; ?>" id="<?php echo $row_rsPromotionen['PROMID']; ?>" src="<?php echo $row_rsPromotionen['PromotionBanner']; ?>" width="775" height="225" alt="<?php echo $row_rsPromotionen['Promotion']; ?>" title="<?php echo $row_rsPromotionen['Promotion']; ?>"/></a></div>
<?php } while ($row_rsPromotionen = mysql_fetch_assoc($rsPromotionen)); ?>
</form>

Update code:

<?php
// WA DataAssist Update
if (($_SERVER["REQUEST_METHOD"] == "POST") && (isset($_SERVER["HTTP_REFERER"]) && strpos(urldecode($_SERVER["HTTP_REFERER"]), urldecode($_SERVER["SERVER_NAME"].$_SERVER["PHP_SELF"])) > 0) && isset($_POST)) // Trigger
{
$WA_connection = $ullrich_db;
$WA_table = "promotionen";
$WA_redirectURL = "".$row_rsPromotionen['LinkToURL'] ."";
if (function_exists("rel2abs")) $WA_redirectURL = $WA_redirectURL?rel2abs($WA_redirectURL,dirname(__FILE__)):"";
$WA_keepQueryString = false;
$WA_indexField = "PROMID";
$WA_fieldNamesStr = "Clicks";
$WA_fieldValuesStr = "".$row_rsPromotionen['Clicks']+1 ."";
$WA_columnTypesStr = "none,none,NULL";
$WA_comparisonStr = "=";
$WA_fieldNames = explode("|", $WA_fieldNamesStr);
$WA_fieldValues = explode($WA_AB_Split, $WA_fieldValuesStr);
$WA_columns = explode("|", $WA_columnTypesStr);

$WA_where_fieldValuesStr = "".$row_rsPromotionen['PROMID'] ."";
$WA_where_columnTypesStr = "none,none,NULL";
$WA_where_comparisonStr = "=";
$WA_where_fieldNames = explode("|", $WA_indexField);
$WA_where_fieldValues = explode($WA_AB_Split, $WA_where_fieldValuesStr);
$WA_where_columns = explode("|", $WA_where_columnTypesStr);
$WA_where_comparisons = explode("|", $WA_where_comparisonStr);

$WA_connectionDB = $database_ullrich_db;
mysql_select_db($WA_connectionDB, $WA_connection);
@session_start();
$updateParamsObj = WA_AB_generateInsertParams($WA_fieldNames, $WA_columns, $WA_fieldValues, -1);
$WhereObj = WA_AB_generateWhereClause($WA_where_fieldNames, $WA_where_columns, $WA_where_fieldValues, $WA_where_comparisons );
$WA_Sql = "UPDATE `" . $WA_table . "` SET " . $updateParamsObj->WA_setValues . " WHERE " . $WhereObj->sqlWhereClause . "";
$MM_editCmd = mysql_query($WA_Sql, $WA_connection) or die(mysql_error());
if ($WA_redirectURL != "") {
if ($WA_keepQueryString && $WA_redirectURL != "" && isset($_SERVER["QUERY_STRING"]) && $_SERVER["QUERY_STRING"] !== "" && sizeof($_POST) > 0) {
$WA_redirectURL .= ((strpos($WA_redirectURL, '?') === false)?"?":"&").$_SERVER["QUERY_STRING"];
}
header("Location: ".$WA_redirectURL);
}
}
?>

Thanks for any help on this.

Sign in to reply to this post

Jason ByrnesWebAssist

in the anchor link add a url variable to pass the image ID, for example:

<a href="<?php echo $row_rsPromotionen['LinkToURL']; ?>?id="<?php echo $row_rsPromotionen['PROMID']; ?>">
in this example the image is passed as a GET variable named id

now open the binding panel, click the plus button and Select URL Variable, name the new variable id. this creates a binding for the id variable in the link.

in the update record behavior, set thew ID field to the PROMID column in your table, and bind the ID value to the id url binding you created.

Sign in to reply to this post

info4753

Thanks Jason. Didn't know that this problem can be solved like this. I found a solution with a redirect page and an update before page loads, but your solution seems to be easier.

Sign in to reply to this post

Jason ByrnesWebAssist

you're welcome.

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...