In my application I have to create a table for each user, the tables are created the first time when the user uploads a file and with the name table_ $ id_user. And the only way I can see to create it dynamically is this:
$sql_create_table1 =
"CREATE TABLE IF NOT EXISTS 'db'.'table1' (
'id' INT NOT NULL AUTO_INCREMENT,
'name' VARCHAR(50) NULL ,
...
PRIMARY KEY ('id') )
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
COLLATE = utf8_unicode_ci;";
$mysqli->query( $sql_create_table1 );
...
I have seen a lot of things over the years and I chose to do so without having much sense if I was doing the right thing.
Is it okay to do this this way?
What problems can arise when creating tables?
Is there another way to do this?
I had a lot of questions about how to program in PHP by reading this answer .