PREZI PREZI - 8 months ago 29
PHP Question

Using the multi query function to modify table after clear button is clicked

$DBConnect = @mysqli_connect("localhost", "username", "password")

$query = "DELETE FROM hitcounter";

$query = "ALTER TABLE hitcounter AUTO_INCREMENT=0";

if (isset($_POST['clear']))



// I made a hit counter which displays hits on page

// Only thing i have left is the reset button that switch the pages hits to 0 after the clear button is pressed

// I am unable to execute the query



You can use:

$query = "TRUNCATE TABLE hitcounter;"

Which will delete all rows and reset the auto_increment to 0 as well in only one query.


This does not work for InnoDB tables as long they have a relationship