advancedfuture Posted January 13, 2008 Share Posted January 13, 2008 Well i was working on a very basic search form and for some reason I can't it to return anything. I even put the query into query browser to check if my syntax is correct (it is!) but still it returns nothing. I am trying to search the column 'resume' for specific keyword(s) which i know exist in the column but still nothing... =( Fulltext indexing is enabled. Any idea's by looking at my code why this wouldn't be returning any results? <?php include 'dbconnect.php'; echo '<form name="form1" id="form1" method="post" action=""> <input type="text" name="search_text"> <input type="submit" name="search" value="Search"> </form>'; //EXECUTE IF THE SEARCH FORM IS ACTIVATED if($_POST['search']) { $search_text = $_POST['search_text']; $query = "SELECT *, MATCH (resume) AGAINST ('$search_text') AS score FROM profile WHERE MATCH (resume) AGAINST ('$search_text') ORDER BY score DESC"; $results = mysql_query($query); while($row = mysql_fetch_array($results)) { echo $row['username']."<br />"; echo $row['headline']."<br />"; } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/85876-solved-fulltext-search-returns-nothing/ Share on other sites More sharing options...
revraz Posted January 13, 2008 Share Posted January 13, 2008 May want to try using LIKE with % wildcard instead of Match and Against. Quote Link to comment https://forums.phpfreaks.com/topic/85876-solved-fulltext-search-returns-nothing/#findComment-438403 Share on other sites More sharing options...
phpSensei Posted January 13, 2008 Share Posted January 13, 2008 <?php include 'dbconnect.php'; echo '<form name="form1" id="form1" method="post" action=""> <input type="text" name="search_text"> <input type="submit" name="search" value="Search"> </form>'; //EXECUTE IF THE SEARCH FORM IS ACTIVATED if($_POST['search']) { $search_text = $_POST['search_text']; $query = "SELECT *, MATCH (resume) AGAINST ('$search_text') AS score FROM profile WHERE `resume` like '$search_text%' ORDER BY score DESC"; $results = mysql_query($query); while($row = mysql_fetch_array($results)) { echo $row['username']."<br />"; echo $row['headline']."<br />"; } } ?> I think thats how it works, i just don't know what fields your searching. Quote Link to comment https://forums.phpfreaks.com/topic/85876-solved-fulltext-search-returns-nothing/#findComment-438405 Share on other sites More sharing options...
advancedfuture Posted January 13, 2008 Author Share Posted January 13, 2008 <?php include 'dbconnect.php'; echo '<form name="form1" id="form1" method="post" action=""> <input type="text" name="search_text"> <input type="submit" name="search" value="Search"> </form>'; //EXECUTE IF THE SEARCH FORM IS ACTIVATED if($_POST['search']) { $search_text = $_POST['search_text']; $query = "SELECT *, MATCH (resume) AGAINST ('$search_text') AS score FROM profile WHERE `resume` like '$search_text%' ORDER BY score DESC"; $results = mysql_query($query); while($row = mysql_fetch_array($results)) { echo $row['username']."<br />"; echo $row['headline']."<br />"; } } ?> I think thats how it works, i just don't know what fields your searching. This returned 1 result.... despite the fact my query should match multiple results... Quote Link to comment https://forums.phpfreaks.com/topic/85876-solved-fulltext-search-returns-nothing/#findComment-438407 Share on other sites More sharing options...
advancedfuture Posted January 13, 2008 Author Share Posted January 13, 2008 for that matter of fact i tried something outrageous... i tried this query SELECT *, MATCH(resume) AGAINST('blaasdasdasdasdasdasdasadsdasdasda') from profile and it returned every row in table 'profile'... and i can tell you this much "blaasdasdasdasdasdasdasadsdasdasda" doesn't exist in any 'resume' column.... hmmm still stumped Quote Link to comment https://forums.phpfreaks.com/topic/85876-solved-fulltext-search-returns-nothing/#findComment-438422 Share on other sites More sharing options...
phpSensei Posted January 13, 2008 Share Posted January 13, 2008 It searches for a keyword in the text, like A B C...etc or a word APPLE, JUICE...etc Quote Link to comment https://forums.phpfreaks.com/topic/85876-solved-fulltext-search-returns-nothing/#findComment-438429 Share on other sites More sharing options...
advancedfuture Posted January 14, 2008 Author Share Posted January 14, 2008 So I figured out what was wrong... Apparently NOTHING was wrong with my first query that I posted... but apparently MySQL has to have more than 3 rows in the database for the MATCH AGAINST to work properly.... Learning something new everyday! Quote Link to comment https://forums.phpfreaks.com/topic/85876-solved-fulltext-search-returns-nothing/#findComment-438434 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.