Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $row2 = [];
- $search_word = false;
- if(isset($_POST["submit"])) {
- //edit this with your credentials
- $con = mysqli_connect("localhost", "root", "uThx6wuf", "search");
- if(mysqli_connect_error()) echo "Connection Fail";
- else {
- $search_word = true;
- $input = $_POST["s_input"];
- // tokenize input
- $tokens = tokenize($input);
- //compute weight of every token
- $token_weight = compute_weight($tokens, $con);
- $sql2 = "SELECT *, match(description) against('". $input ."') as score FROM search where match(description) against('".$input."') order by score desc";
- $result2 = mysqli_query($con, $sql2);
- $sql3 = "SELECT * FROM search";
- $numDocs = (mysqli_num_rows(mysqli_query($con, $sql3)));
- $maxOverlap = sizeof($tokens);
- $ctr2 = 0;
- while($ctr2 != $maxOverlap){
- //compute inverse_document_frequency of term
- $sql3 = "SELECT *, match(description) against('".$tokens[$ctr2]."') FROM search where match(description) against('".$tokens[$ctr2]."')";
- $docFreq = (mysqli_num_rows(mysqli_query($con, $sql3)));
- $idf[$tokens[$ctr2]] = idf($numDocs, $docFreq);
- $ctr2++;
- }
- mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in
- $sql2 = "SELECT *, match(description, title) against('". $input ."') as score FROM search where match(description, title) against('".$input."') order by score desc";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement