在PHP中检查表是否存在

I want to check if the table in database exists, if not create a table with code

CREATE TABLE Topics (
    id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
    firstname VARCHAR(30) NOT NULL,
    email VARCHAR(70) NOT NULL,
    message TEXT
    )

and if not create a table. I know I have to use it but I don't know what to use before...

If you're using MySQL, use this query:

CREATE TABLE IF NOT EXISTS Topics (
id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
firstname VARCHAR(30) NOT NULL,
email VARCHAR(70) NOT NULL,
message TEXT
)

It will create table only if it does not exist.

You can show tables before creating new table by run this commands together

    USE database_name; -- write your database name
    SHOW TABLES;

OR create table if not exit

CREATE TABLE IF NOT EXISTS Topics (
    id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
    firstname VARCHAR(30) NOT NULL,
    email VARCHAR(70) NOT NULL,
    message TEXT
    )