I almost succeeded into building my sql statement. But here is the result:
Quote:
line
0 INSERT INTO bible (book, book_spoke, recordType, book_title, chapter, chapter_spoke, verse, verse_spoke, text_data) VALUES ()
'1',
'1', '1',
'1', '1', 'gn',
'1', '1', 'gn', 'Genesis',
'1', '1', 'gn', 'Genesis', '1',
'1', '1', 'gn', 'Genesis', '1', '1',
'1', '1', 'gn', 'Genesis', '1', '1', '1',
'1', '1', 'gn', 'Genesis', '1', '1', '1', '1',
'1', '1', 'gn', 'Genesis', '1', '1', '1', '1', 'In the beginning God created the heaven and the earth.'
9 INSERT INTO bible (book, book_spoke, recordType, book_title, chapter, chapter_spoke, verse, verse_spoke, text_data) VALUES ('1', '1', 'gn', 'Genesis', '1', '1', '1', '1', 'In the beginning God created the heaven and the earth.')
line
'1',
'1', '1',
'1', '1', 'gn',
'1', '1', 'gn', 'Genesis',
'1', '1', 'gn', 'Genesis', '1',
'1', '1', 'gn', 'Genesis', '1', '1',
'1', '1', 'gn', 'Genesis', '1', '1', '2',
'1', '1', 'gn', 'Genesis', '1', '1', '2', '2',
18 INSERT INTO bible (book, book_spoke, recordType, book_title, chapter, chapter_spoke, verse, verse_spoke, text_data) VALUES ('1', '1', 'gn', 'Genesis', '1', '1', '2', '2', )
'And the earth was without form, and void; and darkness was upon the face of the deep. And the Spirit of God moved upon the face of the waters.'
line
'1',
'1', '1',
'1', '1', 'gn',
'1', '1', 'gn', 'Genesis',
'1', '1', 'gn', 'Genesis', '1',
'1', '1', 'gn', 'Genesis', '1', '1',
'1', '1', 'gn', 'Genesis', '1', '1', '3',
27 INSERT INTO bible (book, book_spoke, recordType, book_title, chapter, chapter_spoke, verse, verse_spoke, text_data) VALUES ('1', '1', 'gn', 'Genesis', '1', '1', '3', )
'3',
'3', 'And God said, Let there be light: and there was light.'
|
As you see there is a repetition. Instead it should be:
Quote:
line
9 INSERT INTO bible (book, book_spoke, recordType, book_title, chapter, chapter_spoke, verse, verse_spoke, text_data) VALUES ('1', '1', 'gn', 'Genesis', '1', '1', '1', '1', 'In the beginning God created the heaven and the earth.')
line
27 INSERT INTO bible (book, book_spoke, recordType, book_title, chapter, chapter_spoke, verse, verse_spoke, text_data) VALUES ('1', '1', 'gn', 'Genesis', '1', '1', '1', '1', 'And the earth was without form, and void; and darkness was upon the face of the deep. And the Spirit of God moved upon the face of the waters.')
line
36 INSERT INTO bible (book, book_spoke, recordType, book_title, chapter, chapter_spoke, verse, verse_spoke, text_data) VALUES ('1', '1', 'gn', 'Genesis', '1', '1', '3', '3',
'And God said, Let there be light: and there was light.')
|
PHP Code:
function recValues(){
$contents_of_page = file_get_contents('../bible1.html');
preg_match_all("#<td.*>(.+)</td#Ui", $contents_of_page, $tdInnerHTML);
$totaltds = count($tdInnerHTML[1]);
$line = 0;
$strLine = array();
for($k=0; $k < $totaltds; $k++){
if($k % 10 == 0){
print("line ");
$strLine[$line] = "";
}
if($k % 10 != 0){
$j = 0;
$tdValues = array();
$tdValues[$j] = $tdInnerHTML[1][$k];
$strLine[$line] .= "'";
//print("'");
$strLine[$line] .= $tdValues[$j];
//print("<span style='font-weight: bold; color: red'>".$tdValues[$j]."</span>");
//print($tdInnerHTML[1][$k]);
if($k % 10 == 9){
$strLine[$line] .= "'";
//print("'<br />\n");
}else{
$strLine[$line] .= "', ";
//print("', ");
}
}
print($strLine[$line]."<br />\n");
//return $strLine[$line];
$j++;
if($k % 9 == 0){
$sql = "INSERT INTO bible (".fields().") VALUES (".$strLine[$line].")";
print("<span style='color: red;'>".$k." ".$sql."</span><br />\n");
$line++;
}
}
}
|