Jump to content

jQuery and PHP to update a table in MySQL


craigtolputt

Recommended Posts

Hi,

 

I am trying to build a jQuery and PHP love it button where the user clicks it and the number increments and saves to a DB.

 

I have it all working apart from the Saving to the DB part : )

 

I have this currently to save but it doesnt seem to work.

<?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++;
}  

?>

 

 

Please see it here http://bit.ly/dKx15z

 

Any ideas??

 

cheers

 

Craig

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.