I have to tables :
tb_document tb_sentence
================= ===========================================
|doc_id|document| | id | sentence_id |sentence | doc_id|
================= ===========================================
I want to take the document data from tb_document. the data is text and then parse the data become sentences.
I need to store maximum 50 sentences only for every document in tb_sentence.
here’s the code :
foreach ($content as $doc_id => $sentences){ //$content is variable that save document from tb_document
$i = 0;
foreach(preg_split('/\\.\\s*/', $sentences) as $current_sentence){
$q = mysql_query("INSERT INTO tb_sentence SET doc_id = {$doc_id}, sentence_id = {$i}, sentence = '{$current_sentence}'") or die(mysql_error());
$i<51; $i++;
}
}
but, it still save whole data. please help me. thank you 🙂
In your code, you compare
$ito 51, but don’t do anything with the comparison. Try:The
breakstatement will exit out of theforeachloop.