所以我需要在我的查询中订购DATE DESC,因为我抓住了最近的5个结果。
$commentquery=mysqli_query($con,"SELECT * FROM user_comments WHERE
content_id='$storyid' ORDER BY date DESC LIMIT 5 ");
while ($comment=mysqli_fetch_array($commentquery)):
然而,在得到我的结果之后,我想颠倒顺序并遍历我的5个结果中最老到最新的。我尝试将mysqli_fetch_Array($ commentquery)放在一个变量中并执行数组反转,但是没有#39 ;似乎是这样做的方式。
答案 0 :(得分:3)
进行查询,对当前记录选择的结果进行排序。
SELECT * FROM
(SELECT *
FROM user_comments
WHERE content_id='$storyid'
ORDER BY date DESC LIMIT 5) last_five_comments
ORDER BY date ASC
答案 1 :(得分:0)
虽然我不明白你为什么不反对你的查询的排序顺序,但那里有一个遗嘱。
Sub Amount()
Dim Lastrow As Long
Dim i As Long
With ActiveSheet
Lastrow = .Cells(.Rows.Count, "C").End(xlUp).Row
For i = 5 To Lastrow
If IsError(.Range("I" & i).Value) Or IsError(.Range("G" & i).Value) Then
.Range("K" & i).Value = "Processed Not Yet Paid"
ElseIf .Range("I" & i).Value <> " " And _
.Range("G" & i).Value = 0 Then
.Range("K" & i).Value = "Paid"
Else
.Range("K" & i).Value = "Processed Not Yet Paid"
End If
Next i
End With
End Sub