Hi,
I'm looping for some help. I've written a script which looks into a folder for .txt files (below)
...and prints the contents of what's in each file to the screen like so:
View Screen
Now what I want to do is take these details and for each file insert them row-by-row in the database like so:
But i'm not sure how to do this part of it where it inserts these details in the database. The rest of it works great. Can anyone kindly help and help me with this code?
Thanks
Chris
PHP Code:
<?php
/* Define and Open the Directory */
$path = '/home/******/parsers/******/write/';
$dir = opendir($path);
/* Loop through the directory using a while loop if $dir exists */
while (false !== ($file = readdir($dir))) {
//Read the files in the directory: one.txt, two.txt, three.txt
$the_text = file_get_contents($path.$file);
//Now need to insert each new line in the database but not sure how???
$SQL = "INSERT INTO test_table (phrase,phrase2,phrase3) VALUES ('$line_one','$line_two','$line_three')";
$QUE = mysql_query($SQL);
echo '<pre>'; print_r($the_text); echo '</pre>';
}
?>