Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6605943
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:20:35+00:00 2026-05-25T19:20:35+00:00

So all i need to do is refresh a variable displayed on a php

  • 0

So all i need to do is refresh a variable displayed on a php page which is stored in a MySQL db. This value is an int which is subtracted by 1 everytime the submit button from a form is clicked. As i’ve opted to use AJAX to post the form the page isn’t being refreshed, therefore the value isn’t being updated along with the form submission.

$qry = mysql_query("SELECT codes_remaining FROM users WHERE email= '".$_SESSION['email']."'");
while($row = mysql_fetch_array($qry)) {
    if ($row['codes_remaining'] ==1 ) 
    {
    echo "You have ".$row['codes_remaining'].' code remaining';
    }
    else {
echo "You have ".$row['codes_remaining'].' codes remaining';
}
}

So this code just displays how many “codes” a person has left. I need this value to be refreshed once the submit button has been clicked from the form on the same page.

I’m using the following JavaScript to not refresh the page.

$("#form-submit").click(function(e) { 
        e.preventDefault();
        $.ajax({
        cache: true,
        type: 'POST',
        url: 'process-register.php',
        data: $("#form-register").serialize(),
        success: function(response) {
            $("#output-div").html(response);
        }
        });
    }); 

Thanks,
LS

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T19:20:36+00:00Added an answer on May 25, 2026 at 7:20 pm

    If you’d like to update the value, do it like this (jQuery is easiest):

    $(".submit").click(function(event) { 
         event.preventDefault();
         $(this).load('file.php',function(val){
            $('#output').text(val);
         });
     });
    

    And in file.php:

    <?php
        connect_to_db();
        $returned = get_info_from_db();
        echo $returned;
    ?>
    

    The jQuery will grab the info on file.php and put it into #output.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got a reasonably simple query (this time) that I need ALL the results
I've been trying to get this code to work for hours! All I need
I have multiple threads (C# application running on IIS) running that all need to
All I need is a way to make a property of one class only
I need to all of timestamps in a column the same amount. I want
I need to retrieve all rows from a table where 2 columns combined are
I need to enumerate all the user defined types created in a SQL Server
I need to list all files whose names start with 'SomeLongString'. But the case
I need to replace all WinAPI calls of the CreateFile, ReadFile, SetFilePointer, CloseHandle with
I need to find all occurrences of a function call in a C++ file

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.