Skip to content
Advertisement

How to sort a table by ID number automatically?

I just want to sort my table by ID number… how can I that with the simplest way? I want to sort that table by “1” “2” “3” automatically.. it will start 1 to 3 (from little one to bigger numbers.)

<table>
<tr>  
<th>ID numbers</th>  
<th>Names</th>
</tr>

<tr>
<td>1</td>
<td>haluk</td>
</tr>

<tr>
<td>2</td>
<td>betul</td>
</tr>

<tr>
<td>3</td>
<td>Erdem</td>
</tr>

<tr>
<td>5</td>
<td>Eylül</td>
</tr>

Thanks…

Advertisement

Answer

<?php
include('database_connection.php');
$sorgu = $baglanti->query("select * from makale ORDER BY ID;");
while ($sonuc = $sorgu->fetch_assoc())  {
?>

I added that code in front of my table and fetch_assoc my datas to my table.. than all ordered by ID numbers…

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement