Saving a value and incrementing it using jquery
Hi All,
I am making a LOVE IT button using php and jquery and i have most of it working...
The button currently returns the value from the DB of 0 but when i click the button it wont save the incremented value to the DB.
my code is this
- <?php
- mysql_connect("localhost", "web183-loveit", "password") or die ("Error.");
- mysql_select_db("web183-loveit") or die ("error");
- $increase = "UPDATE results SET value=value+1 WHERE id=1;";
- $active_rate = mysql_query("SELECT * FROM results WHERE id=1;");
- $val = 0;
- if($rt = mysql_fetch_assoc($active_rate)) {
- $val = $rt['value'];
- }
- if($_POST['action'] == 'add') {
- mysql_query($increase);
- print $val++;
- }
- ?>