I make you a semplified example of my problem and then try to explain it:
<?php
$connect = mysqli_connect($link, $user, $pw, $db);
$informations = mysqli_fetch_array(mysqli_query($connect, "SELECT * FROM table WHERE id = '$id' "));
if($_POST['submit']){
if($informations['show'] == 'true'){
if($informations['changes'] <= '100'){
$value = mysqli_real_escape_string($connect, $_POST['value']);
mysqli_query($connect, "UPDATE table SET changes=changes+1, value='$value' WHERE id = '$id'");
}else{
echo "You made too much changes.";
}
}else{
echo "You cannot change this.";
}
}
if($informations['show'] == 'true'){
echo "<form action='' method='post'>";
echo "<input type='text' name='value' /><input type='submit' name='submit' value='Update' />";
echo "</form>";
}
echo "<br/>You currently have made ".$informations['changes']." changes";
?>
So, looking at this code I can see this:
I enter my page and have a text input near a submit button
Under this i have written "You currently have made 0 changes."
If I press the submit button my page refresh and I can see:
A text input near a submit button
Under this i have written "You currently have made 0 changes."
If i refresh the page this time I can see:
A text input near a submit button
Under this i have writte "You currently have made 1 changes."
So what i wanna ask you is:
Is there any way to perform the update and directly see the changes on the page after the normal form refresh?
I cannot put the "update query" above the "select query" because before make the update i need to check the values of the user....
I know I may use AJAX but it's seems weird that php cannot do that without AJAX, and that takes more time...
Any help will be appreciated, thank you!