如何按降序获取mysql数据?

So my application gets mysql data in json format and displays it in id1 to id* I have to update my database table every day and I want to show the recent data first, I don't want to change the entire table structure each and every time I update my database.

Is there any way that I can add rows in ascending order and fetch data in descending order so that my app will show the fresh data first?

Here is the encoder:

$connection = mysqli_connect("domain", "database user", "password", "database name");
$id = $_GET["id"];
$query = "SELECT * FROM my_data WHERE id BETWEEN ($id+1) AND ($id + 10)";
$result = mysqli_query($connection, $query);

while ($row = mysqli_fetch_assoc($result)) {
    $array[] = $row;    
}

header('Content-Type:Application/json');
echo json_encode($array);

use order by desc like this

Select * from my_data where id between ($id+1) and ($id+10) order by id desc

Here your data shorted in descending order. and order follow in id. if you want to do order with any other field. than you can give name of field instead of id.

for refference see this :

SQL Order By

your code should be like this

<?php 

$connection = mysqli_connect("domain","database user","password","database name");
    $id = $_GET["id"];
    $query = "Select * from my_data where id between ($id+1) and ($id+10) order by id desc";
    $result = mysqli_query($connection,$query);
    while ($row = mysqli_fetch_assoc($result)) {

        $array[] = $row;    
    }
    header('Content-Type:Application/json');
    echo json_encode($array);

 ?>

Hope this will help you!!