Hello! There is an interesting problem. There is a set date, for example 2014-07-02. There is a table in the posts
database, where the user adds one entry every day, and it’s something like this:
+----+----------------------------------+------------+ | id | title | date | | 1 | Очень хороший день | 2014-07-10 | | 2 | Неплохой день | 2014-07-09 | | 3 | Хороший день | 2014-07-08 | | 4 | Могло быть и лучше | 2014-07-07 | | 5 | Не доделал что хотел | 2014-07-06 | | 6 | Забыл вчера написать | 2014-07-05 | | 7 | Начал следить за собой | 2014-07-03 | | 8 | Стартуем | 2014-07-02 | +----+----------------------------------+------------+
I need to display statistics for the last week, relative to that date, and display it to the user, the main indicator: var final = Missing entries this week - 0.
To solve this problem, I need to get the last 7 records, and compare them with the dates of the last 7 days. The task for the user is not to allow var final to be greater than 1. For me the task, if greater than 1 is the value, output the appropriate message.
I wrote a function in php, which receives an array of the last 7 days, but then I don’t know how to tie everything together:
if ( ! function_exists('get_array_seven_day')) { function get_array_seven_day() { $array = array(); for($i=1;$i<8;$i++) { $array[] = date('d.m',strtotime(date('dmY H:i:s'))-60*60*24*$i); } return $array; } }
php
tosql
, PHP to solve the problem in general no side. Well, that is, you can teach the hare to smoke, but it is better to think in a different direction :-) - user6550date
, INTERVAL '1' WEEK)> = NOW (); Compare the result with the number of days in a week (on my planet it is 7) and that's it, don’t look for unnecessary problems. - dekameron pm