Displaying last entered N records

Display last N number of records form MySql Database by selecting results in descending order using ID.

Example

<?php
$con = mysqli_connect("localhost", "username", "password", "database");
 
// Check connection
if (mysqli_connect_errno()) {
    echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
 
// execute query by sorting ID in table by descending order, will display last records  
$Query = "SELECT * FROM newrecords ORDER BY ID DESC LIMIT 10";
$result = mysqli_query($con, $Query);
 
// displaying results
echo "<ul>";
while ($row = mysqli_fetch_array($result)) {
    echo '<li>' . $row['ID'] . '</li>'; /* name of the database column ID */
    echo '<li>' . $row['Name'] . '</li>'; /* name of the database column Name */
}
echo "</ul>";
 
?>