inserting files text from DIR to MySQL

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jaunty Edward

    inserting files text from DIR to MySQL

    Hi,
    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>
    tag.

    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
    script...lol please send the query that i should google.

    Thank you very much

    Regards
    Jaunty Edward
  • Marcel

    #2
    Re: inserting files text from DIR to MySQL


    "Jaunty Edward" <smilesinblues@ hotpop.com> schreef in bericht
    news:1ec8978e.0 409132306.2561d bd2@posting.goo gle.com...[color=blue]
    > Hi,
    > 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>
    > tag.
    >
    > 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
    > script...lol please send the query that i should google.
    >
    > Thank you very much
    >
    > Regards
    > Jaunty Edward[/color]

    Hi Jaunty,

    You should open the dir with something similair like below:

    $handle=opendir ('D:/mydir/');

    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_descrip tion_line = $contents[5];

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

    }

    closedir($handl e);

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

    Regards,

    Marcel


    Comment

    • Jaunty Edward

      #3
      Re: inserting files text from DIR to MySQL

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

      Comment

      Working...