$mysqli = new mysqli("localhost", "username", "password", "database_name"); $tables = $mysqli->query("SHOW TABLES"); while ($row = $tables->fetch_array()) { echo $row[0] . "
"; }
$pdo = new PDO("pgsql:host=localhost;dbname=database_name", "username", "password"); $tables = $pdo->query("SELECT tablename FROM pg_catalog.pg_tables WHERE schemaname = 'public'"); foreach ($tables as $table) { echo $table['tablename'] . "These code examples use different database extensions and query syntax, but the getTables() method is used in both cases to retrieve a list of tables. The mysqli and PDO extensions are both included with PHP, and are commonly used for database connections.
"; }