View Full Version : Enter value into Mysql Database via Button

03-11-2010, 01:33 AM
Hi I want to be able to update a value in a Mysql database using a button and then current values on screen to show the change, I dont want to have the page refresh but use javascript/ajax to post the update to the database then refresh the values on the page.

E.g A number is first retrieved from the database and is displayed when the page is loaded. When a button on the page is pressed then a value is added to the first number, it is updated in the database and the figure on screen is refreshed to show the new value.

03-11-2010, 05:20 PM
Other than giving you links to tutorials on how to use Ajax, what was it you wanted us to tell you?

Actually I will be helpful after all and suggest you use jQuery for the Ajax calls. VERY easy.

jQuery code:

$('#updateBtn').click(function() {
$("#displayedValue").load("update.php"), function(data) {});

And then your update.php script actually updates the database.

03-11-2010, 06:10 PM
This is the PHP forum. You can load a database value when the page is loaded, but it can't update without refreshing the page. You'd need to check out the JS or AJAX forum.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum