virtuexru Posted February 20, 2007 Share Posted February 20, 2007 Ok. I have this search setup so far, to search using a Full-Text index. Now I'm having some problems. I can't find keywords with things like "C#" or "C++" or "Java" (Java maybe too short?) but am OK when searching for "Windows" or "Engineer". Thats my first question. Second main question is, How do I create filters? Such as filtering one row like "City"? Here's my code so far: <?php $keyword = $_POST['keyword']; $results = " SELECT *, MATCH(title, description, location, category) AGAINST('$keyword') AS score FROM joborder WHERE MATCH(title, description, location, category) AGAINST('$keyword') ORDER BY score DESC"; $rest = mysql_query($results); ?> <table width="100%" border="0" cellspacing="0" cellpadding="2"> <?php if (!$rest) { echo mysql_error(); } while($row = mysql_fetch_array($rest)) { $url = 'http://www.website.com/viewlog.php?id='.$row['number'].''; $html = '<a href="'.$url.'">'.$row['title'].'</a>'; echo "<tr bgcolor=\"#99CCFF\"><td><b>{$html}</b></td>"; echo "<td>{$row['location']}</td></tr>"; echo "<tr bgcolor=\"#CCCCCC\"><td>{$row['description']}</td>"; echo "<td>{$row['salary']}<br/></td></tr>"; echo "<tr><td> </td><td> </td></tr>"; } echo "</table>"; ?> Quote Link to comment Share on other sites More sharing options...
fenway Posted February 21, 2007 Share Posted February 21, 2007 It's a limitation of full-text indexing to ignore certain characters... Quote Link to comment Share on other sites More sharing options...
virtuexru Posted February 22, 2007 Author Share Posted February 22, 2007 Ah alright, that's what I thought it was. Any knowledge on how I would go about putting in filters? Quote Link to comment Share on other sites More sharing options...
shoz Posted February 22, 2007 Share Posted February 22, 2007 What do you mean by filtering? Quote Link to comment Share on other sites More sharing options...
virtuexru Posted February 22, 2007 Author Share Posted February 22, 2007 Like say, I have columns for "Category". How would I create say, like check boxes for 4 categories: Blue Red Yellow Green The user wants to search keyword "car" only in the "Green" category.. How would I go about implementing this? Quote Link to comment Share on other sites More sharing options...
shoz Posted February 22, 2007 Share Posted February 22, 2007 SELECT *,MATCH(title, description, location, category) AGAINST('$keyword') AS score FROM joborder WHERE category = 'Green' AND MATCH(title, description, location, category) AGAINST('$keyword') ORDER BY score DESC"; If you're looking for help with the PHP code for this you should post in the PHP_Help forum. Quote Link to comment Share on other sites More sharing options...
virtuexru Posted February 22, 2007 Author Share Posted February 22, 2007 Wow thank you Shoz! That worked perfectly. I just do a quick if(!$variable) statement to see whether or not checkboxes have been filled in or what not. Here's the new code: // $catin = checkbox variable input $keyword = $_POST['keyword']; $catin = $_POST['catin']; if(!$catin) { $results = " SELECT *, MATCH(title, description, location, category) AGAINST('$keyword') AS score FROM joborder WHERE MATCH(title, description, location, category) AGAINST('$keyword') ORDER BY score DESC"; $rest = mysql_query($results); } else { $results = " SELECT *, MATCH(title, description, location, category) AGAINST('$keyword') AS score FROM joborder WHERE category = '$catin' AND MATCH(title, description, location, category) AGAINST('$keyword') ORDER BY score DESC"; $rest = mysql_query($results); } Quote Link to comment 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.