Get the abstract from the contents of documents from a table
<p>I have table that consist of some columns, one of them are <code>document_content</code> column (contents of journals) with the text type. I want to parse the contents to get the abstract. I assume that abstract is the content between the words <code>abstract</code> itself and <code>introduction</code>.</p>

<p>here's my code :</p>

<pre><code>$id = array('1','2','3','4','5','6','7','8','9');
$sql = mysql_query('SELECT document_id, document_content FROM tbdocument WHERE document_id IN (' . implode(",", $id) . ')') or die(mysql_error());
while ($row = mysql_fetch_array($sql)) {
    $files[$row['document_id']] = $row['document_content'];
}
foreach ($files as $doc_id =&gt; $file){
   if (strpos($file, 'ABSTRACT')){
        if (strpos ($file, 'INTRODUCTION')){
            $between  = substr($file, (strpos($file, 'ABSTRACT')+8), (strpos($file, 'INTRODUCTION')-13) - strpos($file, 'ABSTRACT'));
   if (strpos($file, 'Introduction')){
            $between  = substr($file, (strpos($file, 'ABSTRACT')+8), (strpos($file, 'Introduction')-13) - strpos($file, 'ABSTRACT'));
   }
   }
   else {
        if (strpos($file, 'Abstract')){
            if (strpos ($file, 'Introduction')){
                $between  = substr($file, (strpos($file, 'Abstract')+8), (strpos($file, 'Introduction')-13) - strpos($file, 'Abstract'));
            }
            if (strpos($file, 'INTRODUCTION')){
                $between  = substr($file, (strpos($file, 'Abstract')+8), (strpos($file, 'INTRODUCTION')-13) - strpos($file, 'Abstract'));
            }
        }
    }   
    $q = mysql_query("INSERT INTO tb_metadata SET document_id = {$doc_id}, metadata_abstract = '{$between}'") or die(mysql_error());

}
</code></pre>

<p>but it gives me blank result. what's wrong with my code? thank you very much :)</p>
