如何重新排列表的数据顺序?

I have already uploaded my website to the internet. But I need to change the order of entering data to my table. The new records appear at the bottom of the table instead i need it to be at the top. How can I do this?

Please use sort by (id) OR

When You have updated or created date then use sort by (created or updated) date. That will solve your problem.

Sort By means order by in your query

For Example :

ORDER BY column_name DESC

to display the latest on the top, you need to ORDER your results set by descending order.

But to order by descending order ( To get the latest on the top ) you need to have a column in your table with Integer value ( probably your primary key ) or Date.

Here is an example.

Assume I'm having a table in my DB called, Events and here is the structure of the table

enter image description here

Now i'm going to display the results without ordering, which means now the id=7 result should display on the top. Here is the php code for that

<table class="table table-striped">
<?php
require_once('../DB/connect.php');
$result4= mysql_query("SELECT * from events  ");
while ($row= mysql_fetch_array($result4)){
$e_id=$row['id'];
$e_name=$row['ename'];
echo'<tr><td> <img src="../imgs/settings/event5.png" class="img-responsive"></td><td><b>'.$e_name.'</b> </td>';
echo'<td><a button type="button" href="#'.$e_id.'" data-toggle="modal" class="btn btn-primary"> EDIT  </a>

</td>
<td><button type="button" class="btn btn-danger"> DELETE  </button>
</tr>';
}
?>
</table>

Now the above code will give me a result like this.

enter image description here

you can see my older record display on the top.

Now I'm going to change my sql query a bit to display the latest/newest record on the top.

<table class="table table-striped">
<?php
require_once('../DB/connect.php');
$result4= mysql_query("SELECT * from events ORDER by id DESC  ");
while ($row= mysql_fetch_array($result4)){
$e_id=$row['id'];
$e_name=$row['ename'];
echo'<tr><td> <img src="../imgs/settings/event5.png" class="img-responsive"></td><td><b>'.$e_name.'</b> </td>';
echo'<td><a button type="button" href="#'.$e_id.'" data-toggle="modal" class="btn btn-primary"> EDIT  </a>

</td>
<td><button type="button" class="btn btn-danger"> DELETE  </button>
</tr>';
}
?>
</table>

so the above code will give me a result like this,

enter image description here

Like that, you can display the latest result on the top by using ORDER BY column_name DESC