<?php

include 'update_cluster.php';
ini_set('max_execution_time', 30000);
for ($i = 0; $i < count($_FILES['pdf']['name']); $i++) {
    $col = $_FILES['pdf']['name'][$i];
    $filename = explode(".", $col);
    $column_name = $filename[0];
    similar_doc($column_name);
}
function similar_doc($mat1)
{
    $col_name = $mat1;
    $host = "";
    // Host name
    $username = "";
    // Mysql username
    $password = "";
    // Mysql password
    $db_name = "";
    // Database name
    $con = mysql_connect($host, $username, $password) or die(mysql_error());
    mysql_select_db($db_name, $con) or die(mysql_error());
    $doc1 = $col_name;
    $doc2 = "AaronPressman";
    $doc3 = "AlanCrosby";
    $doc4 = "AlexanderSmith";
    $doc5 = "BenjaminKangLim";
    $doc6 = "BernardHickey";
    $doc7 = "BradDorfman";
    $doc8 = "DarrenSchuettler";
        $m++;
        echo $val;
        echo "\n";
        $query13 = "update rownum_terms2 set {$column_name}={$val} where rownum={$m}";
        $data = mysql_query($query13) or die(mysql_error());
    }
    unset($TF_IDF_array);
}
$queryb = "select column_name from information_schema.columns where table_schema='test' and table_name='rownum_terms2'";
$resultb = mysql_query($queryb);
while ($datab = mysql_fetch_array($resultb)) {
    array_push($new_cols, $datab['column_name']);
}
//print_r($new_cols);
foreach ($new_cols as $key => $val) {
    if (in_array($val, $old_cols)) {
        echo $val;
        echo "Up to date";
        echo "\n";
        echo "\n";
        echo "\n";
        echo "\n";
    } else {
        similar_doc($val);
        //echo $val;
    }
}
mysql_close($con);
?>