how to reverse fetch assoc in php

Solutions on MaxInterview for how to reverse fetch assoc in php by the best coders in the world

showing results for - "how to reverse fetch assoc in php"
Simona
21 Aug 2017
1while($row = mysql_fetch_assoc($result)){
2    $items[] = $row;
3}
4
5$items = array_reverse($items ,true);
6
7foreach($items as $item){
8   echo $item['time']." - ".$item['username']." - ".$item['message'];
9}
10
11//another option can be
12
13$query = mysql_query("SELECT * FROM (
14                      SELECT time, username, message
15                      FROM messages ORDER BY time 
16                      DESC LIMIT 10) result 
17                      ORDER BY time ASC   
18                    ");