How to display inserted data in a website's database?

I’ve created a website on https://www.000webhost.com/ and uploaded a PHP code to be capable of inserting data into the website’s MYSQL database but now i’d like to show(display) this data in the website’s home page for example
i’m sure there’s some way that might be the easiest to display the data tables from the MYSQL database clearly on the website using HTML

You Want To Fetch datas from your database Rigth?

if yes, What Do you want to display?
post?
user profile?

Yes
A table of data maybe , we upload using a PHP code for insertion and now we’d like to show that data in the website’s home page

Show your Data tables

It’s just a simple one for testing

1112

https://www.bitdegree.org/learn/mysql-select-database

<?php
echo "<table style='border: solid 1px black;'>";
echo "<tr><th>Id</th><th>Firstname</th><th>Lastname</th></tr>";

class TableRows extends RecursiveIteratorIterator { 
    function __construct($it) { 
        parent::__construct($it, self::LEAVES_ONLY); 
    }

    function current() {
        return "<td style='width:150px;border:1px solid black;'>" . parent::current(). "</td>";
    }

    function beginChildren() { 
        echo "<tr>"; 
    } 

    function endChildren() { 
        echo "</tr>" . "\n";
    } 
} 

$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "myDBPDO";

try {
    $conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
    $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    $stmt = $conn->prepare("SELECT id, firstname, lastname FROM MyGuests"); 
    $stmt->execute();

    // set the resulting array to associative
    $result = $stmt->setFetchMode(PDO::FETCH_ASSOC); 
    foreach(new TableRows(new RecursiveArrayIterator($stmt->fetchAll())) as $k=>$v) { 
        echo $v;
    }
}
catch(PDOException $e) {
    echo "Error: " . $e->getMessage();
}
$conn = null;
echo "</table>";
?>