inserting files text from DIR to MySQL

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
My problem is a little advance I feel, please check it and guide me if
you can.

I have a lot of similar format text files, that has name in the first
line then age in forth line second and then discription of the person
in the 6 line which is a lot of text para and does not have any <br>

What I want is to have a script that can read the files in the folder
and populate the database with all the files.

I can play with php a little but I am not a programmer of that quality
so I wanted to read more of the php for this perticular script,

I will be thankful if any one from can tell me what things in php I
read to study and if there are any resources that I can use to get it
and can use for this script.
I know php I can install and make database applications and I am
comfortable till variables and DB based applications, however
functions, classes and arrays are something that i am not a expert of.

I think my question is a little dump but i cant pay and i need this please send the query that i should google.

Thank you very much

Jaunty Edward

Re: inserting files text from DIR to MySQL

Quoted text here. Click to load it

Hi Jaunty,

You should open the dir with something similair like below:


while (false!==($file = readdir($handle))) {

    $contents = file('D:/mydir/'.$file,"r"); // $contents is an array
containing every line of the file

    $age_line = $contents[0]; // $age_line contains also the end of line
character(s) so you will have to remove them

    $person_description_line = $contents[5];

    // after retrieving data from file put your sql statements here



Try something like this, the above isn't tested by me but should point you
in the right direction.



Re: inserting files text from DIR to MySQL

thank you so much I will try this and start studying similar things,
thank you very much Marcel.

Site Timeline