The code While($row=mysql_fetch_assoc($res)) return rows 1,2,3...n-1,n.
I need after to get from the same $res (not to make new query) the rows but in another order n,n-1,...,2,1.
It is possible?
You can use mysqli_data_seek() function.
Example:
$result = mysqli_query( $query );
$totalRows = mysqli_stmt_num_rows( $result );
for( $i=($totalRows-1); $i>=0; $i-- )
{
    mysqli_data_seek( $result, $i );
    $row = mysqli_fetch_row( $result );
}
Please note: You can use mysqli_data_seek only after mysqli_query, mysqli_store_result or mysqli_use_result.
Simple juste reverse array and save it in a new variable.
<?php
  $newvar=array_reverse($array);
 ?>
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With