toonces Posted September 3, 2012 Share Posted September 3, 2012 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; Quote Link to comment https://forums.phpfreaks.com/topic/267942-automating-some-data-entry/ Share on other sites More sharing options...
Barand Posted September 3, 2012 Share Posted September 3, 2012 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 ?> Quote Link to comment https://forums.phpfreaks.com/topic/267942-automating-some-data-entry/#findComment-1374833 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.