0
Hello,
I would like to upload a file .txt
which meets the layout as follows (following example of two lines of the file):
9787546;488464;2016-12-11;Carlos Fonseca;carlos.fonseca
9787547;464664;2016-12-11;Rogério Barros;rogerio.barros
The file maintains this layout and has more than 3 thousand lines.
I would like to know more or less a script that treats the lines, differentiating in columns each data.
What I have today is simple, but only matters the first column:
<?php
$file = fopen('../files/docs/libs/newUsers.txt', 'r');
while(!feof($file)){
$data = fgets($file);
$query = mysqli_query($con,"insert into users values '({$data})'");
}
I know there’s no separation of the columns being made, but it’s the most I could find at the moment.
I don’t code in OO yet.
Thank you!
the table users are with which layout? (ie the fields for insertion, you did not specify in SQL this is not very appropriate.)
– novic
True @Virgilionovic is right. You should play it safe and specify columns and their values
– Miguel
@Virgilionovic I did not specify the columns at first because the layout is all columns present in this table, but I will specify!
– João Vitor