在实际数据库中,我的上载日期为“月”。在此查询中,我想按月,年按时间顺序对表进行排序。但是在仪表板上,每个页面的刷新顺序都会更改。
$sql2="SELECT DATE_FORMAT(Month,'%b %Y') as MonthYear,SUM(Target) AS MonthTarget,Sum(DeliveredTillDate) AS MonthDelivered, (Sum(Target)-Sum(DeliveredTillDate)) AS MonthDeficit FROM spiceworks.dashboard WHERE ClientName='Spiceworks' Group By MonthYear order by MonthYear desc LIMIT 4; ";
$mnthresult = mysqli_query($conn, $sql2);
<table class="table table-hover" style="font-size: 12px;">
<thead>
<tr>
<th >Month</th>
<th>Target</th>
<th >Delivered</th>
<th >Deficit</th>
</tr>
</thead>
<tbody>
<?PHP
while($row = mysqli_fetch_array($mnthresult))
{
echo "<tr>
<td >".$row["MonthYear"]."</td>
<td >".$row["MonthTarget"]."</td>
<td >".$row["MonthDelivered"]."</td>
<td >".$row["MonthDeficit"]."</td>
</tr>";
}
?>
</tbody>
</table>