mysql UPDATE和刷新页面

I've got an issue where the page refreshes faster than the query is executed.

I use an UPDATE query to update my database with some values in my fields. And I got this under a button. But When I push this button (Which will refresh my website) it still shows the old values in my fields.

When I refresh the page again, it shows the values that I filled in. I added a image for a better explanation.enter image description here

I execute the query for getting the information for the table right away in my php code:

$dates = getStartAndEndTime($currentWeek, $currentYear);

$Query = "SELECT * FROM Productielijn1 WHERE Datum BETWEEN ? AND ? ORDER BY Datum";
if($stmt = $dbCon->prepare($Query))
{
    $stmt->bind_param('ss', $dates[0], $dates[1]);

    if( $stmt->execute() === TRUE)
    {
        $Result = $stmt->get_result();

        while($row = $Result->fetch_assoc())
        {
            $ArrayGegevens[] = $row;
        }
    }   
}

And when I press the button I do this:

//First edit button
if(isset($_POST['btnEdit1']))
{
    $date = strip_tags($_POST['Datum1']);

    $tempo = strip_tags($_POST['Tempo1']);
    $proddescrip = strip_tags($_POST['Productomshrijving1']);
    $amount = strip_tags($_POST['Aantal1']);

    $displayDate = date("d-m-Y", strtotime($date));

    $Query = "UPDATE productielijn1 SET Tempo= ?, Productomschrijving= ?, Aantal= ? WHERE Datum = ?";

    if($stmt = $dbCon->prepare($Query))
    {
        $stmt->bind_param('isis', $tempo, $proddescrip, $amount, $date);

        if( $stmt->execute() === TRUE)
        {
            $Message2 = "De waardes van " . $displayDate ." zijn aangepast.";
            $MessageColor2 = "green"; 
        }
        else
        {
            $Message2 = "Het aanpassen is niet gelukt!";
            $MessageColor2 = "red"; 
        }
    }   
}

And I create my table like this:

    <table class ="PlanningTable">
        <tr>
            <th colspan='5'>Planning aanpassen voor huidige week (<?php echo $currentWeek ?>)</th>
        </tr>
        <tr>
            <th>Datum</th>
            <th>Tempo</th>
            <th>Product omschrijving</th>
            <th>Aantal/Volume</th>
            <th>Aanpassen</th>
        </tr>

        <?php
        if (count($ArrayGegevens) != 0)
        {
            for ($k = 1; $k < count($ArrayGegevens)+1; $k++)
            {
                echo "<tr>";
                echo "<td><input type='date' name='Datum".$k."' value='".$ArrayGegevens[$k-1]['Datum']."'readonly></td>";
                echo "<td><input type='number' name='Tempo".$k."' value= '" .$ArrayGegevens[$k-1]['Tempo'] . "'></td>";
                echo "<td><input type='text' name='Productomshrijving".$k."' value ='". $ArrayGegevens[$k-1]['Productomschrijving'] ."'></td>";
                echo "<td><input type='number' name='Aantal".$k."' value='" . $ArrayGegevens[$k-1]['Aantal'] . "'></td>";
                echo "<td><input type='submit' name='btnEdit".$k."' value='Aanpassen'></td>";
                echo "</tr>";
            }   
        }
        else
        {
            echo"<tr>";
            echo "<td colspan='5' style='color: red;'>Voor deze week is er nog geen planning!</td>";
            echo "</tr>";
        }

        ?>
        <tr>
            <td colspan=5><p class="Message" style='color: <?php echo $MessageColor2 ?>;'><?php echo $Message2 ?></p></td>
        </tr>
    </table>

So is there a way that it will update my html values right away?

Change your code to:

<!-- language: lang-html -->

    if(isset($_POST['btnEdit1']))
    {
        $date = strip_tags($_POST['Datum1']);

        $tempo = strip_tags($_POST['Tempo1']);
        $proddescrip = strip_tags($_POST['Productomshrijving1']);
        $amount = strip_tags($_POST['Aantal1']);

        $displayDate = date("d-m-Y", strtotime($date));

        $Query = "UPDATE productielijn1 SET Tempo= ?, Productomschrijving= ?, Aantal= ? WHERE Datum = ?";

        if($stmt = $dbCon->prepare($Query))
        {
            $stmt->bind_param('isis', $tempo, $proddescrip, $amount, $date);

            if( $stmt->execute() === TRUE)
            {
                $Message2 = "De waardes van " . $displayDate ." zijn aangepast.";
                $MessageColor2 = "green"; 
            }
            else
            {
                $Message2 = "Het aanpassen is niet gelukt!";
                $MessageColor2 = "red"; 
            }
        }

              echo "<script>
                setTimeout(function(){
                    location.reload();
                }, 300);
                </script>";


}

Adding js code.