Skip to content
Advertisement

PHP/MYSQL: A removed row is still displayed in my page after a reload

I work on a simple webserver on a Raspberry Pi, displaying a MySQL table with two buttons : One (Switch) to inverse a boolean value, and one (Delete) to remove the entire row from the table.

What I do, basically, is a while loop on the MySQL table in which I : 1 : display the row and the buttons in a form, and 2 : check if the buttons have been clicked, and if so I send the query to the database and reload the page.

My problem is very simple : When I click on a “switch” button, the query is sent and the page is refreshed, and the value is correctly modified (the page display the value as it is in the database). But when I click on the other button, the “delete” one, after the page has been reloaded, the row still appears in the table. Only when I manually reload the page, the row disappear.

What I already tried : 1 : Check that the row is removed from the database BEFORE the manual refresh : DONE, and the row is correctly removed. 2 : Wait 500ms after the MySQL query, and then reload the page : DONE, and even when I wait 500ms, when the page reloads there is still the removed row.

Here is the whole code, the MySQL query is at the end :

JavaScript

Maybe someone saw this problem before ?

Advertisement

Answer

whell you are have problem with redirect. check this link to know more about redirect

Before you continue please backup your code.

To fix your problem you must move your <?php endwhile; ?> after

JavaScript

then add input hidden after formname “Delete”

JavaScript

and the last replace this:

JavaScript

With this

JavaScript

Im not say this is are the good solution. but it will solve your problem until you found the best solution.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement