It is necessary that when clicking on a link, a new table is created in the database:

create table otchet ( id_user int (10) AUTO_INCREMENT, name varchar(20) NOT NULL, email varchar(50) NOT NULL, password varchar(15) NOT NULL, PRIMARY KEY (id_user) ); 

The problem is that when you re-create a table with the same name, sql will naturally return a warning that a table with that name exists. How to make the table name change with each request. For example: otchet (1), otchet (2) ... otchet (n);

  • On the question: you can stupidly sort through the names of the tables until the table is created. You can create a configuration table, where to write the recorded table number and the next time you create a new table, increment the counter. But this is not correct, it is better to do as they say in response - to create not a new table, but a new report - BOPOH
  • I have values ​​in the report only from the base. PS I use the library PHPExcel - Mr.Slow
  • You didn’t clarify the situation how much) and looked at the structure of the table - and where is the report? This is the username / password of the user. Do you want to create your own table for each user? Why, if you can use one table, create it, and add the data already to the existing table - BOPOH
  • I did not give all the fields, as I only need to understand the meaning. And I was wrong, if I create a new table every time, then the script needs to specify it every time, and this is haemorrhoids. - Mr.Slow
  • It is easier to update the table, with each query, using INSERT IGNORE or ALTER IGNORE TABLE, indexing the fields - Mr.Slow

1 answer 1

You need to create an intermediate table with a group of reports, and add to the reports (all in one table) the group field id. So it will be better than creating new tables.

Read