Jump to content

Recommended Posts

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 />";
}

}
?>

Link to comment
https://forums.phpfreaks.com/topic/85876-solved-fulltext-search-returns-nothing/
Share on other sites

<?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.

<?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...

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

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!

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.