jeppers Posted September 15, 2010 Share Posted September 15, 2010 hi there i am looking to build a button counter. and i am wondering of you could help. i want the button to +1 every time someone clicks it and also store the value so it can be used as a voucher code. can anyone help thanks Quote Link to comment Share on other sites More sharing options...
plznty Posted September 16, 2010 Share Posted September 16, 2010 So you want a Button click counter? and the number should be saved where? I could help with this info. Quote Link to comment Share on other sites More sharing options...
chintansshah Posted September 16, 2010 Share Posted September 16, 2010 Please find the code below. <?php if(is_set($_POST['submit']) { //please conect and select db $query = mysql_query("insert into tabname values('valueofcnt','vouchercode')"; } $sql = mysql_fetch_row(mysql_query("SELECT counter_val from tabname ORDER BY counter_val DESC LIMIT 1")); ?> <form action="" method="post"> <input type="submit" name="submit" value="<?=$sql[0]?>"> </form> Quote Link to comment Share on other sites More sharing options...
kla0005 Posted September 16, 2010 Share Posted September 16, 2010 Lol - Wouldnt a 'update' not solve the problem better, than 3000 id's in a database? A single row could be enought. Quote Link to comment Share on other sites More sharing options...
jeppers Posted September 22, 2010 Author Share Posted September 22, 2010 in a flat text file which i can then pull up the info and use as a voucher code. 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.