I have a (python) program running that is constantly sending data to a MySQL database, and I use html/php to graph these data. A simple x/y data point graph where x = number of measurement (1, 2, 3...) and y = value of the measurement taken (323, 4938, 2...).
I use a 2 column table, which will add a new row every time a new measurement is taken. I use python/selenium in order to update the page every time a new input is made
//python
driver = webdriver.Chrome(chrome_options=option, executable_path=PATH)
driver.refresh()
I want to add a "RESET" button the page, which will delete the data inside the table. This is the way I am currently trying to achieve this:
<?php
if($_SERVER['REQUEST_METHOD'] == 'POST'){
$handle = $dbconnection->prepare('TRUNCATE TABLE measurements'); //deletes all the data for my x, y graph.
$handle -> execute();
?>
<form action="" method="post">
<input type ="submit" name ='reset' value='RESET' />
<br/>
</form>
This partially works, since it does send the query and deletes the data from my table if I press the button. The problem is that it deletes the table every time the webpage refreshes once I press the button. What I wish would happen is that the table only gets deleted when I press the button, not everytime the webpage refreshes.
How can I change the HTML/PHP code in order for the button to send the query only once it is pressed, and not every time once it is pressed?