Reputation: 31
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...
Upvotes: 1
Views: 528
Reputation: 31
<?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...
Upvotes: 0
Reputation: 23
To sorting the table automatically via Pure HTML seems impossible at all. You still need to use PHP to make a quick sorting. But first all the data must be inside of your database table. An to simply echo out all the info just do some simple looping
<?php
$bil = 1;
$SQL = "SELECT * FROM tablename";
$Query = mysqli_query($connection , $SQL);
while ($row = mysqli_fetch_array($Query)) {
echo "
<tr><td>".$bil++."</td></tr>
";
}
?>
If don't understand feel free to ask
Upvotes: 1