$time_populate = microtime_float(); //Drop data $db->sql("DELETE FROM rpt_broker_buyer_average"); //Get customer service reps $csrs_all= $db->sql("SELECT csr.usr_id FROM csr"); //Start our loop, generate blank rows for all csrs from current date to 2001 of Jan 16th. do { $insert_date = date('m-d-Y', time()); //Loop all reps and insert blank data to database foreach($csrs_all as $csrs_all_data) { $i++; $insert_csr = $csrs_all_data["USR_ID"]; $db->sql("INSERT INTO rpt_broker_buyer_average (REF_BUDGET, REF_SHORT, REF_LONG, REF_DATE, CSR_ID) VALUES('0', '0', '0', TO_DATE('".$insert_date."','MM-DD-YYYY'), '$insert_csr')"); } $current = $current - '86400'; } while ($current > '979452000'); //Time this mess $time_end = microtime_float(); print "Populated table in: ".round($time_end - $time_start, 4)."\n";