I'm trying to keep a running tally of (lets say) button clicks. Each time a user clicks a button I put a record in the database.
$ad_now=(mktime()-21600);
$sql_today = "INSERT INTO total_today (but, date_time) VALUES ('1', '$ad_now')";
$result_today = mysql_query($sql_today);
$sql_yesterday = "INSERT INTO total_yesterday (but, date_time) VALUES ('1', '$ad_now')";
$result_daily = mysql_query($sql_yesterday);
$sql_weekly = "INSERT INTO total_weekly (but, date_time) VALUES ('1', '$ad_now')";
$result_weekly = mysql_query($sql_weekly);
$sql_monthly = "INSERT INTO total_monthly (but, date_time) VALUES ('1', '$ad_now')";
$result_monthly = mysql_query($sql_monthly);
$sql_yearly = "INSERT INTO total_yearly (but, date_time) VALUES ('1', '$ad_now')";
$result_yearly = mysql_query($sql_yearly);
$sql_ytd = "INSERT INTO total_ytd (but, date_time) VALUES ('1', '$ad_now')";
$result_ytd = mysql_query($sql_ytd);
What I can't figure out is how do I SELECT just the records from:
5:00 pm yesterday (end of workday) to now to echo for the $today variable in my page
5:00 pm two days ago to 5:00 pm yesterday to echo for the $yesterday variable in my page
Friday at 5:00 pm to the following friday at 5:00 pm for my $weekly variable
The last day of the month to the last day of the following month for my $monthly variable
Same for year and year to date.
I don't even know where to start, any help would be much appreciated.