0

I am running a db query and display the results on the same page. even tho I run the query before I load the page, I have to refresh before it updates my table. Is there a way to delay the update of the table tell the query finishes?

On the top of the page I have

if (isset($_POST['record']))
{
$user->delete($_POST['record'],1);
}
?>

Lower in the page I have a table that displays a list of users. When I delete a user it runs a form

echo "<form method=\"post\" action=\"" . $_SERVER['PHP_SELF'] . "\" > " ;
echo "<input type=\"hidden\" name=\"action\" value=\"delete\" />";
echo "<input type=\"hidden\" name=\"record\" value=\"".$found['id'] ."\" />";
echo "<a id=\"deleteRecord\" class=\"btn btn-danger\" href=\"#\"><i class=\"fa fa-trash-o\"></i>

The table that contains the form is what I need updated. but after I delete, it loads the table as if the record still exisists. (it is gone in the database) and I have to do a second refresh before it removes the record.

I also tried do do a refresh as part of isset(POST) and it works sometimes. but I think there must be a better way

4
  • 1
    Post some code samples :) Commented Feb 13, 2014 at 20:04
  • added some code samples :) Thanks in advance Commented Feb 13, 2014 at 20:11
  • 1
    Without seeing more of the code I would guess your SELECT query to display the results is being executed before the DELETE query so you have an array of records with the deleted record still there Commented Feb 13, 2014 at 20:15
  • How do I accept a comment. Thank you! Commented Feb 13, 2014 at 20:18

1 Answer 1

1

Without seeing more of the code I would guess your SELECT query to display the results is being executed before the DELETE query so you have an array of records with the deleted record still there

Perform the DELETE query first, then get your records with the SELECT query

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.