kuau
03-10-2009, 12:29 AM
I inherited a website where for the past 4 years every time someone did a price check, it would insert a new record into the 'checks' table with the date and time. This resulted in hundreds of records per day. I have written new code that results in only one record per day that holds the total checks for that day.
I need to write a little one-time script that will "balance forward" the existing data. Basically it needs to do this for each day from 2005-8-19 to the present...
$sql = "SELECT * FROM checks WHERE Ch_Date = '2005-08-19'";
$result = mysql_query($sql,$connection) or die("Couldn't execute $sql query.");
$Price_Checks = mysql_num_rows($result);
$sql = "INSERT INTO newtable ( `checkdate`, `checks` ) VALUES ( '$checkdate', '$Price_Checks' ) ";
$result2 = mysql_query($sql,$connection) or die("Couldn't execute $sql query.");
I don't know how to make the while loop that will increment the day by 1 so it will go through all of the dates. I know this must be simple, but counters were never my forte. Any assistance would be greatly appreciated.
Mahalo, erin :)
I need to write a little one-time script that will "balance forward" the existing data. Basically it needs to do this for each day from 2005-8-19 to the present...
$sql = "SELECT * FROM checks WHERE Ch_Date = '2005-08-19'";
$result = mysql_query($sql,$connection) or die("Couldn't execute $sql query.");
$Price_Checks = mysql_num_rows($result);
$sql = "INSERT INTO newtable ( `checkdate`, `checks` ) VALUES ( '$checkdate', '$Price_Checks' ) ";
$result2 = mysql_query($sql,$connection) or die("Couldn't execute $sql query.");
I don't know how to make the while loop that will increment the day by 1 so it will go through all of the dates. I know this must be simple, but counters were never my forte. Any assistance would be greatly appreciated.
Mahalo, erin :)