4
Well, I need to spend two in the php query, but I can’t pass them otherwise:
$coluna = implode( ',' , $colunas);
$date = implode( " ',' " , $dates);
$teste2 = "'$date'";
//O teste2 está gerando algo como: 'exemplo', 'exemplo'
$sql = "INSERT INTO $table ($coluna)
VALUES ($teste2)";
if ($conn->query($sql) === TRUE) {
echo "<br>Dados enviados com sucesso!";
}
else {
echo '<br>Não foi possível enviar os dados!';
}
The way it worked out, but I thought it was too much to do it this way, I believe there’s some better way to do it!
$columns and $Dates are the arrays that are coming in, their size is undefined, since I will pass this data in several places.
I put " ',' "as implode
I recommend using parameterized queries instead of playing the values this way, as it may be vulnerable to SQL Injection.
– Renan Cavalieri
I think that ORM can help you in this case.
– Papa Charlie
You can also use serialize: http://php.net/manual/en/function.serialize.php . But use prepare to prevent sql Injection
– Bruno Folle
Is this Mysqli or PDO? Why can it make a difference
– Guilherme Nascimento