Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Mar 2010
    Thanked 0 Times in 0 Posts

    Enter value into Mysql Database via Button

    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.

  • #2
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Thanked 637 Times in 625 Posts
    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.

  • #3
    Senior Coder
    Join Date
    May 2005
    Thanked 72 Times in 72 Posts
    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.
    Rowsdower! has accused me of having mental problems, and the administrator allowed it. What a great forum huh?


    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts