Jump to content

resetting stats


ldoozer

Recommended Posts

why would you have so many tables with respect to a single data type (number of page request?)

 

 

Should be a single table and then you could easily just write.

 

 

<?php
$q = "Update `Reqest_Count_table` Set Hit_Count = '0'";
$r = mysql_query($q) or die(mysql_error()."<br /><br />".$q);
?>

 

That would update all counts to 0 in that table

Link to comment
https://forums.phpfreaks.com/topic/88200-resetting-stats/#findComment-451293
Share on other sites

if the field name is consitent across the database say

<?php
$tables = array("table1", "Table2");
$update_field = "Hit_Cont";
foreach($tables as $value){
$q = "Update `".$value."` Set ".$update_field."='0'";
$r = mysql_query($q) or die(mysql_error()."<br /><br />".$q);
}
?>

 

 

Should work.

Link to comment
https://forums.phpfreaks.com/topic/88200-resetting-stats/#findComment-451302
Share on other sites

If the columns have a default value of 0, couldn't you just use

$sql = mysql_query("TRUNCATE TABLE table_name");

 

 

 

No!

 

Truncate will empty all records out of a table

 

Right. he said he wanted to reset all to zero. I take that as meaning 'starting from scratch'. If each column has a default value of 0, then he will achieve his goal. Otherwise, why reset to zero?

Link to comment
https://forums.phpfreaks.com/topic/88200-resetting-stats/#findComment-451462
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.