Search
 
SCRIPT & CODE EXAMPLE
 

PHP

how to reverse fetch assoc in php

while($row = mysql_fetch_assoc($result)){
    $items[] = $row;
}

$items = array_reverse($items ,true);

foreach($items as $item){
   echo $item['time']." - ".$item['username']." - ".$item['message'];
}

//another option can be

$query = mysql_query("SELECT * FROM (
                      SELECT time, username, message
                      FROM messages ORDER BY time 
                      DESC LIMIT 10) result 
                      ORDER BY time ASC   
                    ");
Comment

PREVIOUS NEXT
Code Example
Php :: if value conatins in word check in php 
Php :: laravel auth ui command 
Php :: run python script from batch file with arguments 
Php :: how unset request parameter in laravel 
Php :: laravel get url without domain in blade 
Php :: php index of last element in array 
Php :: php check if associative array is null 
Php :: laravel validation allow empty array 
Php :: php pass by reference 
Php :: eloquent get query log 
Php :: array should not be empty php 
Php :: laravel firstorcreate 
Php :: get localstorage value in php 
Php :: difference between fetch assoc and fetch array or object php 
Php :: laravel orderby with relation 
Php :: get raw query laravel 
Php :: laravel display error message 
Php :: limit 1 1 in laravel query 
Php :: How to fix MySql: index column size too large (Laravel migrate) 
Php :: Invalid request (Unsupported SSL request) 
Php :: php memory usage view 
Php :: password strength php 
Php :: nl2br php 
Php :: how to update radio button value in database using php 
Php :: laravel storage get file path 
Php :: continue php 
Php :: how to get auth user name in laravel 
Php :: laravel run seeder 
Php :: name csrf token laravel mismatch 
Php :: PHP Numeric String 
ADD CONTENT
Topic
Content
Source link
Name
2+7 =