Jump to content

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

just realised that I dont have the class that connects to the db. need to do this:

$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);
}
?>

but in sql?

Link to comment
https://forums.phpfreaks.com/topic/88200-resetting-stats/#findComment-451326
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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.