I have two problems and have no idea how to solve them. I have the following PHP/MySQL table on one of my sites:
<table>
<thead>
<tr>
<th>1</th>
<th>2</th>
<th>Coins</th>
</tr>
</thead>
<tbody>
<?php
error_reporting(E_ALL);
define ( 'MYSQL_HOST', 'localhost' );
define ( 'MYSQL_BENUTZER', 'USER' );
define ( 'MYSQL_KENNWORT', 'PASSWORD' );
define ( 'MYSQL_DATENBANK', 'DATABASE' );
$db_link = mysqli_connect (
MYSQL_HOST,
MYSQL_BENUTZER,
MYSQL_KENNWORT,
MYSQL_DATENBANK
);
$sql = "SELECT * FROM TABLE";
$db_erg = mysqli_query( $db_link, $sql );
if ( ! $db_erg )
{
die('Ungültige Abfrage: ' . mysqli_error());
}
while ($zeile = mysqli_fetch_array( $db_erg, MYSQL_ASSOC))
{
echo "<tr>";
echo "<td>". $zeile['1'] . "</td>";
echo "<td>". $zeile['2'] . "</td>";
echo "<td>". $zeile['coins'] . "</td>";
echo "</tr>";
}
mysqli_free_result( $db_erg );
?>
</tbody>
</table>
Row 3 only contains numbers. How do I make the table:
- Sort the the numbers in the column coins from largest to smallest [According to the size]
- Only display 20 rows after getting the "best" ones?