So I need simple thing, I need to create button in my website, after button is clicked, It should truncate database table, but I can't do It successfully by myself. So could you help me, please?
Here I'm trying to creeate button:
<input type="button" id='delete' class='delete' value='Truncate' onClick="$truncate">
</input>
I know this is wrong way to use PHP variable in HTML, but I don't know how to do It correctly.
Here is my PHP variable:
$truncate= "TRUNCATE TABLE myTable";
With connection to database is all right:
$mysqli = new mysqli("localhost","database","password","asd");
So maybe here is better method to create button for truncate database's table? Thank you.
UPDATED:
This won't work too, nothing happens after button is clicked.
if(isset($_POST['delete'])){
$delete= "TRUNCATE TABLE myTable";
}
?>
<input type="button" id='delete' class='delete' name="delete" value='Truncate' onClick="delete">
</input>