Advertisement
Guest User

Untitled

a guest
Jul 5th, 2015
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. $row2 = [];
  2. $search_word = false;
  3. if(isset($_POST["submit"])) {
  4. //edit this with your credentials
  5. $con = mysqli_connect("localhost", "root", "uThx6wuf", "search");
  6.  
  7. if(mysqli_connect_error()) echo "Connection Fail";
  8. else {
  9. $search_word = true;
  10. $input = $_POST["s_input"];
  11.  
  12. // tokenize input
  13. $tokens = tokenize($input);
  14.  
  15. //compute weight of every token
  16. $token_weight = compute_weight($tokens, $con);
  17.  
  18. $sql2 = "SELECT *, match(description) against('". $input ."') as score FROM search where match(description) against('".$input."') order by score desc";
  19.  
  20. $result2 = mysqli_query($con, $sql2);
  21.  
  22. $sql3 = "SELECT * FROM search";
  23. $numDocs = (mysqli_num_rows(mysqli_query($con, $sql3)));
  24.  
  25. $maxOverlap = sizeof($tokens);
  26. $ctr2 = 0;
  27. while($ctr2 != $maxOverlap){
  28. //compute inverse_document_frequency of term
  29. $sql3 = "SELECT *, match(description) against('".$tokens[$ctr2]."') FROM search where match(description) against('".$tokens[$ctr2]."')";
  30. $docFreq = (mysqli_num_rows(mysqli_query($con, $sql3)));
  31. $idf[$tokens[$ctr2]] = idf($numDocs, $docFreq);
  32. $ctr2++;
  33. }
  34.  
  35. mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in
  36.  
  37. $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