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

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.