recset Posted September 10, 2006 Share Posted September 10, 2006 I am trying to create a click counter for records in my database with the following code:[code]// *** Hits Counter ***$urlparam = "passit";$ckrs = "quotes"; //used for identificationif (!isset($HTTP_SERVER_VARS["QUERY_STRING"])) { $HitLink = $HTTP_SERVER_VARS["PHP_SELF"] . "?" . $urlparam . "=";} else { $HitLink = $HTTP_SERVER_VARS["PHP_SELF"] . "?" . $HTTP_SERVER_VARS["QUERY_STRING"] . "&" . $urlparam . "=";}if (isset($HTTP_GET_VARS[$urlparam])) { $tableName = "wisdom_backup"; $fieldName = "ID"; $hitsfield = "Counter"; $urlfield = "PATH"; // Get the Hits number and update it. $rsCon = "vlot"; $IdSource = "select * from " . $tableName . " where " . $fieldName . " = " . $HTTP_GET_VARS[$urlparam] . ""; $rsId = mysql_query($IdSource, $$rsCon) or die(mysql_error()); $row_rsId = mysql_fetch_assoc($rsId); $hiturl = $row_rsId[$urlfield]; $next = $row_rsId[$hitsfield] + 1; $upd = "update " . $tableName . " set " . $hitsfield . " = " . $next . " where " . $fieldName . " = " . $HTTP_GET_VARS[$urlparam] . ""; $rsId = mysql_query($upd, $$rsCon) or die(mysql_error()); $rsId = null; header("Location: " . $hiturl);}[/code]And this is the code for the actual link:[code]<a href="<?php echo $HitLink . $row_quotes["ID"] ?>">Download</a>[/code]Now, it does everything that I want it to do (counts hits everytime it is clicked) however, in the URL path, it adds:[code]&passit=46[/code] the '46' refers to the record ID, now if a user keeps on clicking different record ID's, it will keep on adding the 'passit' url parameter, for example it would look like:[code]&passit=46&passit=22&passit=34&passit=5[/code]And so on and so on. Is there a way to clear the url parameters once the link has been clicked, but still store the data that its supposed to store?? Link to comment https://forums.phpfreaks.com/topic/20326-click-counter/ Share on other sites More sharing options...
corbin Posted September 11, 2006 Share Posted September 11, 2006 I would explode row_quotes into an array and only pass the last var=val Link to comment https://forums.phpfreaks.com/topic/20326-click-counter/#findComment-89573 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.