在PHP中从数据库到底部的第一个值

I want to display data as a tertis block game

Current display:

-0.1
+0.22
-0.33
-0.4

Expected display:

-0.4
-0.33
+0.22
-0.1

I have tried using array_reverse and array_unshift. But no satisfying result.

This is the code:

$result="select x1,y1,angle1 from csv_data ORDER BY x1 "; //query on database 
$output=mysqli_query($con,$result); //no.of rows 
$rowcount=mysqli_num_rows($output); //fetching all data 
$row=mysqli_fetch_all($output,MYSQLI_ASSOC);

for($i=0;$i<$rowcount;$i++) {
    echo $row[$i]['x1']."\t".$row[$i]['y1']."\t".$row[$i]['angle1']."<br>"; 
    ob_flush();
    flush(); 
    sleep($delay);
}

I want to display last updated value at top and first read value to settle at bottom of page

Why don't you do a manual swap?

// Get your result
$result = mysqli_query($conn, $sql);
$arr = mysqli_fetch_array($result);

//Then do a manual swap
$tmp = $arr[0];
$arr[0] = $arr[count($arr) - 1];
$arr[count($arr) - 1] = $tmp;

Your question isn't clear, are you refering to this?

Change your for loop to:

for ($i = $rowcount-1; $i>=0; $i--) { 
   ...
} 

:D