php - 检查数据库和表是否存在,如果不存在,则创建它

I have a db_connect.php which holds all information for the database. I now want to check if database exists and if not, create it.

Then i want to check if the used table exists, and if not, create it. Anyone have an idea how I exactly do this?

Here is my db_connect.php:

<?php
//outsourced db-informations
$db_host = 'localhost';
$db_user = 'root';
$db_passwort = '';
$db_name = 'test_db';
$db_table = 'data';
$db_mysqli = mysqli_connect("$db_host","$db_user","$db_passwort", "$db_name");
mysqli_connect("$db_host","$db_user","$db_passwort", "$db_name") or die
("Keine Verbindung moeglich");
?>

The query will look like

CREATE TABLE IF NOT EXISTS tbl_user (
id INT NOT NULL AUTO_INCREMENT,
PRIMARY KEY(id),
uname    CHAR(10) NOT NULL,
regdate  DATE NOT NULL)