\n"; echo "Vertaal een woord (Nederlands, Engels of Koreaans)
\n"; echo "단어를 번역합니다 (네덜란드어, 영어 혹은 한국어)
\n"; echo "Translate a word (Dutch, English or Korean)

\n"; // connect to mysql database "korea" include ("/home/hznytcfb/domains/kordut.be/.htpasswd/kordut_web_connect.php"); // select the query we are going to use if ($wordcount=="2"){ $joinword2 = str_replace(" ","",$joinword1); $joinword3 = str_replace(" ","-",$joinword1); $query = "SELECT Veld1, Veld2, Veld3 FROM dutch_korean WHERE Veld1 in ('$joinword1', '$joinword2', '$joinword3') or Veld2 in ('$joinword1', '$joinword2', '$joinword3') or Veld3 in ('$joinword1', '$joinword2') OR AltSpell in ('$joinword1', '$joinword2', '$joinword3') LIMIT 100"; } else { $query = "SELECT Veld1, Veld2, Veld3 FROM dutch_korean WHERE Veld1='$woord2' OR Veld2='$woord2' OR Veld3 RLIKE '^$korwoord2$' OR AltSpell='$woord2' LIMIT 100"; } // perform the query echo "Searched word \"$woord\" :
\n"; $result = mysql_query($query) or die( mysql_error() ); if (mysql_num_rows($result) > 0){ echo "\n"; // fetch the data from the database while($row = mysql_fetch_row($result)){ $veld1 = $row[0]; $veld2 = $row[1]; $veld3 = $row[2]; $encoded1 = urlencode($veld1); $encoded2 = urlencode($veld2); $encoded3 = urlencode($veld3); echo "\n"; } echo "
NederlandsEnglishKorean
 $veld1  $veld2  $veld3 
"; }else{ echo "Sorry, the exact word was not found\n"; } // insert searched word into search table $veld1 = str_replace("'","''",$veld1); $veld2 = str_replace("'","''",$veld2); $query = "INSERT INTO search (search, dutch, english, korean, ip, UnixTime, browser) VALUES ('$woord2', '$veld1', '$veld2', '$veld3', '$ip', UNIX_TIMESTAMP(), '$browser')"; // perform the action $result = mysql_query($query) or die( mysql_error() ); // perform LIKE wordsearch if ($wordcount=="2"){ $query = "SELECT Veld1, Veld2, Veld3 FROM dutch_korean WHERE Veld1 LIKE '%$joinword1%' OR Veld2 LIKE '%$joinword1%' OR Veld3 LIKE '%$joinword1%' OR AltSpell LIKE '%$joinword1%' OR Veld1 LIKE '%$joinword2%' OR Veld2 LIKE '%$joinword2%' OR Veld3 LIKE '%$joinword2%' OR AltSpell LIKE '%$joinword2%' OR Veld1 LIKE '%$joinword3%' OR Veld2 LIKE '%$joinword3%' OR AltSpell LIKE '%$joinword3%' LIMIT 100"; } else { $query = "SELECT Veld1, Veld2, Veld3 FROM dutch_korean WHERE Veld1 LIKE '%$woord2%' OR Veld2 LIKE '%$woord2%' OR Veld3 RLIKE '$korwoord2' OR AltSpell LIKE '%$woord2%' LIMIT 100"; // like search exept equal, but it fails on NULL value fields // $query = "SELECT Veld1, Veld2, Veld3 FROM dutch_korean WHERE (Veld1 LIKE '%$woord2%' OR Veld2 LIKE '%$woord2%' OR Veld3 LIKE '%$woord2%' OR AltSpell LIKE '%$woord2%') AND Veld1 != '$woord2' AND Veld2 != '$woord2' AND Veld3 != '$woord2' LIMIT 100"; } // perform the query $result = mysql_query($query); if (mysql_num_rows($result) > 0){ echo "

"; echo "Words that partly contain \"$woord\" :\n"; echo "\n"; // fetch the data from the database while($row = mysql_fetch_row($result)){ $veld1 = $row[0]; $veld2 = $row[1]; $veld3 = $row[2]; echo "\n"; } echo "
NederlandsEnglishKorean
$veld1$veld2$veld3
\n"; }else{ echo ", and a search for partly use of this word also returned no results.
\n"; // does the searched word contain korean characters? $value = 0; for ($i=0; $i < strlen($woord2); $i++) { $asciivalue = ord(substr($woord2,$i)); $value = $value + $asciivalue;} $value = $value / $i; // search for simular sounding words if the searched word is not Korean if ($value < 150 && $woord2 != "qq"){ $query = "SELECT Veld1, Veld2, Veld3 FROM dutch_korean WHERE soundex(Veld1)= soundex('$woord2') OR soundex(Veld2)= soundex('$woord2') ORDER BY Veld1 ASC LIMIT 100"; $result = mysql_query($query); if (mysql_num_rows($result) > 0){ echo "

"; echo "Did you mean any of the following words?
\n"; echo "\n"; // fetch the data from the database while($row = mysql_fetch_row($result)){ $veld1 = $row[0]; $veld2 = $row[1]; $veld3 = $row[2]; echo "\n"; } echo "
NederlandsEnglishKorean
$veld1$veld2$veld3
\n"; } } } echo "

\n"; echo "\n"; echo "\n"; echo "
\n"; $endtime = microtime(); $endtime = explode(" ",$endtime); $endtime = $endtime[1] + $endtime[0]; $totaltime = ($endtime - $starttime); $totaltime = round($totaltime,3); echo "Database search took ".$totaltime." seconds"; //echo "
Wordcount = $wordcount
"; include ("bottom2.php"); }else{ // ob_end_clean(); header("Location: wordsearch1.php"); } ?>