Display data on same page as form without refresh

If I understand correctly

  • you need the original form to display the values of what has just been posted.
  • You also need the table to display 0 on values that haven’t been calculated.
  • At the moment the table calculates information perfectly with a submit refreshing the page.

You can use the if(isset($_POST["fieldname"])){ variable you have above to do this.

if(isset($_POST["fieldname"])){ echo $_POST["fieldname"]

would echo the value of what has been posted, ie text in a text box. In your case it is a checkbox so you use something like this instead:

<input type="checkbox" name="txtCheck" value="your value" <?php if(isset($_POST['txtCheck'])) echo "checked='checked'"; ?>  />

You can do the same with the table. If you want it to be 0 before calculation (without seeing your table code)

Something like this in your cell:

if (empty($cellvalue)) echo '0'; //If there is no data to display show 0 
else echo $cellvalue;