What are the best practices for printing database records from phpMyAdmin in a readable format?

When printing database records from phpMyAdmin, it's important to format the output in a readable way for users. One way to achieve this is by fetching the records from the database using PHP and then displaying them in a table format on a webpage. This allows for easy readability and organization of the data.

<?php
// Connect to the database
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "database_name";

$conn = new mysqli($servername, $username, $password, $dbname);

// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}

// Fetch records from the database
$sql = "SELECT * FROM table_name";
$result = $conn->query($sql);

// Display records in a table format
echo "<table border='1'>";
echo "<tr><th>ID</th><th>Name</th><th>Email</th></tr>";
while($row = $result->fetch_assoc()) {
    echo "<tr><td>".$row['id']."</td><td>".$row['name']."</td><td>".$row['email']."</td></tr>";
}
echo "</table>";

// Close connection
$conn->close();
?>