= date_add(now(),interval -32 day)"; else $where = ""; mysql_query ("create table traffic_history_month$testonly like traffic_history"); if (!mysql_error()) $where = ""; mysql_query ("alter table traffic_history_month$testonly add primary key traffic_history_ip_month_key (traffic_history_ip,traffic_history_month)"); mysql_query ("replace into traffic_history_month$testonly select traffic_history_ip, last_day(max(traffic_history_date)), traffic_history_month, max(traffic_history_in), max(traffic_history_out), max(traffic_history_total) from traffic_history$testonly $where group by traffic_history_ip, traffic_history_month"); ?>OK