There is a MS SQL server, there is a library for working with this DBMS - sqlsrv. send request:
SELECT * FROM ( SELECT [name], [date], [status], row_number() OVER (PARTITION BY [name] ORDER BY [date] DESC) AS rownum FROM [script_monitoring].[dbo].[script_status] ) [script_monitoring].[dbo].[script_status] WHERE rownum <= 10` I get the answer:
Awayalogs 2017-02-09 23:59:17.363 1 1 Awayalogs 2017-02-08 23:59:15.117 1 2 Awayalogs 2017-02-07 23:59:12.660 1 3 Awayalogs 2017-02-06 23:59:12.580 1 4 Awayalogs 2017-02-05 23:59:16.870 1 5 Awayalogs 2017-02-04 23:59:18.237 1 6 Awayalogs 2017-02-03 23:59:11.577 1 7 Awayalogs 2017-02-02 23:59:16.237 1 8 Awayalogs 2017-02-01 23:59:12.047 1 9 Awayalogs 2017-01-31 23:59:13.300 1 10 DeleteOldBackups 2017-01-31 19:02:20.140 1 1 DeleteOldBackups 2017-01-13 16:39:02.307 0 2 Etc. (96 lines)
Actually the question is how to parse this answer, so that on the basis of each unique name (awayalogs, Deleteoldbackups) form a table of the type:
/awayalogs/ /DeleteOldBackups/ awayalogs 2017-02-09 23:59:17.363 1 DeleteOldBackups 2017-01-31 19:02:20.140 1 awayalogs 2017-02-08 23:59:15.117 1 DeleteOldBackups 2017-01-13 16:39:02.307 0 awayalogs 2017-02-06 23:59:12.580 1 awayalogs 2017-02-06 23:59:12.580 1 That's how I got the data when I needed everything without filtering:
$count_rows = sqlsrv_num_rows($stmt); echo "<table align=\"center\" border=\"1\" cellpadding=\"7\" cellspacing=\"1\"><tr><th>Имя</th><th>Описание</th><th>Дата</th><th>Статус завершения</th></tr>"; $n = 0; while ($n < $count_rows) { echo "<tr>"; echo "<td>" . sqlsrv_get_field($stmt, 0) . "</td>"; echo "<td>" . sqlsrv_get_field($stmt, 1) . "</td>"; echo "<td>" . sqlsrv_get_field($stmt, 2, SQLSRV_PHPTYPE_STRING(SQLSRV_ENC_CHAR)) . "</td>"; if (sqlsrv_get_field($stmt, 3) === 0) { echo "<td bgcolor=\"#FF0000\">" . sqlsrv_get_field($stmt, 3) . "</td>"; } else { echo "<td bgcolor=\"#CCFF99\">" . sqlsrv_get_field($stmt, 3) . "</td>"; } echo "</tr>"; $n++; $row = sqlsrv_fetch($stmt, SQLSRV_SCROLL_NEXT); } echo "</table>"; (just don’t throw in minuses I’m just not experienced in this business I don’t know how to form a question correctly)