Parabolundertow Posted March 2, 2007 Share Posted March 2, 2007 Hi there, I am trying to run a counter so when a person clicks on a banner, it updates the db with a new number. I have called the banner link: ad_counter.php?id=1 I have a field in my table called ad_counter Then im setting a recordset to GET the data. I am using: $last = $row_Recordset1['ad_counter']; $add = 1; $ad_counter = $last + $add; What I want to do is auto form fill and update the database, and proceed to their website without this process even being seen. Is this possible without having to push the form submit button. A basic statistics gatherer for businesses who wish to advertise. Thankyou Quote Link to comment Share on other sites More sharing options...
skali Posted March 2, 2007 Share Posted March 2, 2007 I have called the banner link: ad_counter.php?id=1 Modify this link to modify banner link to: ad_counter.php?id=1&do=update On your ad_counter.php page if($_GET['do']=='update && !empty($_GET['id']){ //update your database counter. } Quote Link to comment Share on other sites More sharing options...
Parabolundertow Posted March 2, 2007 Author Share Posted March 2, 2007 hi skali Thanks for the quick reply. if($_GET['do']=='update && !empty($_GET['id']){ //update your database counter. } How does this know which field in the table to update? I want to update the field (ad_counter) Should this work? Quote Link to comment Share on other sites More sharing options...
skali Posted March 2, 2007 Share Posted March 2, 2007 if($_GET['do']=='update && !empty($_GET['id']){ mysql_query('update your_table set ad_counter = ad_conter +1 where ad_id = {$_GET['id']}'); } Quote Link to comment Share on other sites More sharing options...
Parabolundertow Posted March 2, 2007 Author Share Posted March 2, 2007 that looks great - but am i missing something - it wont let me close the ?> text all red from there (Dreamweaver) Quote Link to comment Share on other sites More sharing options...
itsmeArry Posted March 2, 2007 Share Posted March 2, 2007 you are missing a ' here if($_GET['do']=='update use if($_GET['do']=='update' Quote Link to comment Share on other sites More sharing options...
Parabolundertow Posted March 2, 2007 Author Share Posted March 2, 2007 awesome thankyou !!! Sometimes the more you stare at something the more you can't see it. Quote Link to comment Share on other sites More sharing options...
Parabolundertow Posted March 4, 2007 Author Share Posted March 4, 2007 Hi guys, Im still trying to make this work ... Im hoping to call the ad_counter from the table using $_GET, add 1 and update, then go to a url. here is my script: <?php require_once('Connections/Farout.php'); ?> <?php if (isset($_GET['id'])) { $colname_rsBusinessclick = (get_magic_quotes_gpc()) ? $_GET['id'] : addslashes($_GET['id']); } mysql_select_db($database_Farout, $Farout); $query_rsBusinessclick = sprintf("SELECT * FROM hub_directory WHERE id = '%s'", $colname_rsBusinessclick); $rsBusinessclick = mysql_query($query_rsBusinessclick, $Farout) or die(mysql_error()); $row_rsBusinessclick = mysql_fetch_assoc($rsBusinessclick); $totalRows_rsBusinessclick = mysql_num_rows($rsBusinessclick); $ad_counter = $row_rsBusinessclick['ad_counter']; if($_GET['do']=='update' && !empty($_GET['id']){ mysql_query('update hub_directory set ad_counter = ad_counter +1 where id = {$_GET['id']}'); $updateGoTo = "http://www.mywebaddress.com.au"; if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) { $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?"; $updateGoTo .= $HTTP_SERVER_VARS['QUERY_STRING']; } header(sprintf("Location: %s", $updateGoTo)); } ?> Where am I going wrong ... ?? Quote Link to comment Share on other sites More sharing options...
roopurt18 Posted March 4, 2007 Share Posted March 4, 2007 You can only include variables inside of double quoted, not single quoted, strings. Change the single quotes around: 'update hub_directory set ad_counter = ad_counter +1 where id = {$_GET['id']}' to double quotes. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.