Search
Here you can search through content, titles, isbn, authors, and categories to find a specific pdf in your database. Results will have links to pdf/txt.
";
}
//lets search through every table in the database for the search string
$searchStrFound = 0;
$dupe = 0;
$server = 'localhost';
$user = 'root';
$database = 'pdfsToTxt';
$db = mysql_connect($server, $user, $password, $database);
if (!$db)
die("Could Not Connect To Database".mysql_error());
$result = mysql_select_db($database, $db);
if (!$result)
{
$dbSelectError = "
Error Selecting Database
";
//die(mysql_error()); //debugging
}
$result = NULL;
foreach ( $tableNames as $tableName )
{
$result = mysql_query("select content from myPdfs where content like '%$search%' and title like '$tableName'");
if ( $result )
{
$content = NULL;
//load table content to var
while ( $row = mysql_fetch_assoc($result) )
$content .= $row['content'];
//preg_match for search string
$found = preg_match("/$search/i", $content);
if ( $found )
{
//initial load
if ( $searchStrFound == 0 )
{
$searchStrTables[$searchStrFound] = $tableName;
$searchStrFound++;
$sentence = found($tableName, $content, $search);
}
else
{
//check for dupe table name
for ( $x = 0; $x < $searchStrFound; $x++ )
{
if ( $searchStrTables[$x] == $tableName )
$dupe++;
}
//load table name if not a dupe
if ( $dupe == 0 )
{
$searchStrTables[$searchStrFound] = $tableName;
$searchStrFound++;
$sentence .= found($tableName, $content, $search);
}
$dupe = 0;
}
}
}
else //nothing found reset $result just in case
$result = NULL;
}
mysql_close($db);
//check if searchStr was found in any of the tables
if ( $searchStrFound > 0 )
{
$tableContentMatchStr = "
";
$searchStrFound = 0;
}
else
$noSearchContentFound = "
Search string did not match any content within any of the tables
";
}
else
{
$searchWordCntError = "
Search string is too long. Max words: $wordCntMax
Search string is empty
";
}
?>
=$tableNameMatchStr?>
=$tableContentMatchStr?>
=$noSearchContentFound?>
=$tableNameTable?>
=$searchContentError?>
=$noTableNameMatches?>
=$emptySearchError?>
=$searchWordCntError?>
=$dbShowTableError?>
=$dbSelectError?>
=$dbSelectTableError?>
=$sentence?>