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 Link to comment https://forums.phpfreaks.com/topic/213509-php-button-counter/ 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. Link to comment https://forums.phpfreaks.com/topic/213509-php-button-counter/#findComment-1111557 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> Link to comment https://forums.phpfreaks.com/topic/213509-php-button-counter/#findComment-1111568 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. Link to comment https://forums.phpfreaks.com/topic/213509-php-button-counter/#findComment-1111578 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. Link to comment https://forums.phpfreaks.com/topic/213509-php-button-counter/#findComment-1114173 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.