I wrote a script, but it does not work as it should.
The bottom line is that when you add a comment, the client is entered in the database 2 dates:
client_dateA - the date of the last contact;
client_dateB - the date of the next contact;
The system has customer output by date, but it works somehow strange, I need to output the number of COUNT (client_id) records for which the date of the next contact will be less than the current date of the day (this is considered an overdue record, unless its manager commented on the whole day and the next day it becomes overdue) you also need to output the number of clients whose date of the next contact is scheduled for tomorrow and for the week.
Please help me how to do it correctly.
The code that makes the request now
<?php // Подключение скриптов ядра include 'engine/function_mysqlServer.php'; include 'engine/function_configServer.php'; // Подключение скриптов ядра // Проверка авторизации пользователя if (isset($_COOKIE['id']) and isset($_COOKIE['hash'])) { $userdata = mysql_fetch_assoc(mysql_query("SELECT * FROM users WHERE users_id = '".intval($_COOKIE['id'])."' LIMIT 1")); $username = $userdata['users_login']; } // Проверка авторизации пользователя // Вывод 40 записей о клиентах на сегодня $main = mysql_query("SELECT * FROM client WHERE client_manager = '".$username."' and client_dateB = '".$date."' LIMIT 40"); if ($date == $row['client_dateB']) { while ($row_arr = mysql_fetch_array($main)) { echo "<div class=\"content_min\">"; echo "<p style=\"font-size:14px;float:left;font-weight:500;color:#949494;\">".$row_arr['client_company']." (ID: ".$row_arr['client_number'].")</p>"; echo "<p style=\"font-size:14px;float:right;font-weight:500;color:#949494;\">".$row_arr['client_name']."</p><br>"; echo "<p style=\"font-size:14px;float:left;font-weight:500;color:#949494;\">".$row_arr['client_dateA']."</p>"; echo "<p style=\"font-size:14px;float:right;font-weight:500;color:#949494;\">".$row_arr['client_phone']."</p><br><br>"; echo "<p style=\"line-height:20px;color:#676666;\">".$row_arr['client_comment']."</p></div>"; } } else { echo "<div class=\"mess_coffe\">".$username.", на сегодня у Вас отсутствуют записи</div>"; } // Общее количество зарегистрированных клиентов менеджером $sql = mysql_query("SELECT COUNT(client_id) FROM client WHERE client_manager = '".$username."'"); $res_sql = mysql_fetch_row( $sql ); // Общее количество зарегистрированных клиентов менеджером // Просроченные записи на текущий день $overdue = mysql_query("SELECT COUNT(client_id) FROM client WHERE client_manager = '".$username."' and client_dateB < NOW()"); $overdue_result = mysql_fetch_row( $overdue ); // Просроченные записи на текущий день // Зарегистрированные клиенты на завтра $tomorrow = mysql_query("SELECT COUNT(client_id) FROM client WHERE client_manager = '".$username."' and client_dateB > '".$date."'"); $tomorrow_result = mysql_fetch_row( $tomorrow ); // Зарегистрированные клиенты на завтра