PREZI PREZI - 1 year ago 63
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


Answer Source

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download