Jump to content

Automating some data entry


toonces

Recommended Posts

hi people. I have what "should" be a pretty straightforward task to complete, but seeing how i'm not so bright with php i need help...

 

I have mamp installed on my local development machine. I have a database with a table called "products". In that table there's a field called "notes". I have a folder full of text files that were exported from an unrelated program. each one of them is named 1234.txt where "1234" corresponds to the unique value in my key field "serialnumber". There are hundreds of these text files. I want to take the contents of each file and put it in the notes field for the corresponding record. Basically in plain english this is what i want to make a script to do :

 

find a file;

 

strip off the ".txt" from the name;

 

find the record where the filename (minus the .txt) corresponds to a serialnumber value;

 

insert the contents of that text file into the notes field;

 

save the record;

 

keep doing it til you run out of files;

 

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/267942-automating-some-data-entry/
Share on other sites

For finding files in a directory

   

    opendir or

    glob

 

To get the file contents

 

    file_get_contents

 

To get the id from the filename

    
<?php
    $str = '1234.txt';
    $id = intval($str);   //--> 1234
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.