Opa,
I need to capture the textarea text, separate it by lines and then explode and separate it by commas.
$lines = explode("\n", $respostas);
$i = 0;
if ( !empty($lines) )
{
foreach ($lines as $line)
{
$i++;
//Adiciona Respostas
foreach($respostas as $key)
{
$sql = mysqli_query($conn, "INSERT INTO respostas
VALUES (
NULL, $i, '$key'
)");
}
//Adiciona Respostas
}
}
In the mysql insert, I need to save the contents ($ key) to the line ($ i), but it is duplicating the inserts according to the number of rows.
Textarea example:
teste, teste1, teste2
teste3, teste4