1
I have a page that has a textarea and in this textarea the user will put a list of records and in these records I separate the strings with the function explodes
this is my html index.php code
Mtms Ativos #login{ text-align: center text-align margin: 0 auto; padding:40px 15px; }
label{
display: block;
margin-right: 100px;
padding: 5px;
}
#text{
width: 500px;
height: 480px;
}
Function valida(){
if(form.text.value==""){
Alert('Fill in field');
form.text.Focus();
Return false;
}
Alert("Material required successfully!");
}
Alert("test");
--> Material:
<label for="submit"></label>
<input type="submit" name="enviar" class="input_button" id="bt_logar" value="enviar" />
</form>
this is the insert.php code that contains the query
<?php
$conexao = @mysql_connect("localhost","root","") or print("erro");
if (!$conexao) die ("<h1>Falha na conexao com o servidor!</h1>");
$db = @mysql_select_db("test");
if (!$db) die ("<h1>Falha na conexao com o Banco de Dados!</h1>");
$text = $_POST["text"];
//echo $text;
$alterado = array("-");
$alterar = array("");
$replace = str_replace($alterado,$alterar,$text);
$novaString = chunk_split($replace,12,".");
//echo $novaString;
$bat = explode('.',$novaString);
print_r($bat)."<br>";
//insere normalmente
$sql = @mysql_query("insert into test.tab_mtm_ativos (MTM,planta) values ('$bat','B510') on duplicate key update mtm = values(mtm)") or die ("erro");
@mysql_close($conexao, $sql);
header('location: mtm.php');
?>
I advised you to encode as json in the answer below, but remember that by default it is not correct to do this in a relational database. If you are looking for multidimensional and dynamic fields, look for a no-sql solution
– LF Ziron