Hi! Could we please enable some services and cookies to improve your experience and our website?
Online Sandbox for SQL and PHP: Write, Run, Test, and Share SQL Queries and PHP Code
<?php
$query = "create table users (
id INT AUTO_INCREMENT PRIMARY KEY,
name varchar(100),
phone varchar(20),
created_at TIMESTAMP
)";
// get DB version using PDO
$stmt = $pdo->prepare($query);
$stmt->execute();
// foreach ($pdo->query("SHOW TABLES") as $row) {
// print_r( $row );
// }
// $table = 'users';
$stmt = $pdo->prepare("describe ?");
$stmt->execute(['users']);
$columns = $stmt->fetchAll(PDO::FETCH_ASSOC);
print_r($columns);