0
I have some tables that follow a pattern:
NomeUsuário_SobreomeUsuário_IDUsuário_sementes
Jefferson_carlos_1_seeds
Carlos_drummond_2_seeds
the name, surname and ID are stored in the session and I recover to enter in the database:
$ID = $_SESSION['ID'];
$nome = $_SESSION['nome'];
$sobrenome = $_SESSION['sobrenome'];
Then I recover the user informed data:
$ano = $_POST['ano'];
$mes = $_POST['mes'];
$titulo = $_POST['titulo'];
$descricao = $_POST['descricao'];
The query looks like this (or at least I would like it to be):
$sql = " INSERT INTO '$nome'_'$sobrenome'_'$ID'_sementes(ano, mes, titulo, descricao) VALUES ('$ano', '$mes', '$titulo', '$descricao') ";
I echo the query to see how it looked (obviously it was not executed correctly):
INSERT INTO 'Jefferson''Carlos''1'_seeds(year, month, title, description) VALUES ('2017', 'July', 'example title', 'description example')
If I remove the ' :
$sql = " INSERT INTO $nome_$sobrenome_$ID_sementes(ano, mes, titulo, descricao) VALUES ('$ano', '$mes', '$titulo', '$descricao') ";
makes that mistake:
Notice: Undefined variable: name_in /Storage/Emulated/0/www/registra_seed.php on line 23
Notice: Undefined variable: last name_in /Storage/Emulated/0/www/registra_seed.php on line 23
Notice: Undefined variable: Id_seeds in /Storage/Emulated/0/www/registra_seed.php on line 23
And the query prints like this:
INSERT INTO (year, month, title, description) VALUES ('2017', 'July', 'example title', 'description example')
What I do?
You use a table for each user?
– Darlei Fernando Zillmer
Yes, because each user inserts a lot of data
– JeffersonCarlosBD