Basic solution
// Abrir documento fonte
$name_src = "nome_documento.txt";
$h_src = fopen($name_src,"r");
// Leitura linha depois linha até o final
while (($str_src = fgets($h_src)) !== false)
{
// Explode sobre TAB
$tab = explode("\t",$str_src);
// Prepara o query (exemplo com 3 valors per linha)
$query_insert = "INSERT INTO TAB_GARDE_ACT "
."( "
."campo1, "
."campo2, "
."campo3 "
.") "
."VALUES "
."("
."'".$tab[0]."', "
."'".$tab[1]."', "
."'".$tab[2]."' "
.") ";
//Fazer o query (depende do que vc usa Mysql, mysqli, dbp, postgress...)
$result = sql_query($connector,$query_insert);
}
// Fechar documento
fclose($h_src);
Need (normal!) to open the connection with the BDD. If you have a lot of data, you can use a so SQL call. To do this, you need to use mysql_insert_array().
You need to import this only once or it will be a feature of your system?
– André Ribeiro
You will get the option Import file, and you will forget all previous database and replace with current data.
– André Machado