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>"; ?> Link to comment https://forums.phpfreaks.com/topic/39370-solved-need-serious-phpmysql-full-text-search-help/ 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... Link to comment https://forums.phpfreaks.com/topic/39370-solved-need-serious-phpmysql-full-text-search-help/#findComment-190219 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? Link to comment https://forums.phpfreaks.com/topic/39370-solved-need-serious-phpmysql-full-text-search-help/#findComment-191290 Share on other sites More sharing options...
shoz Posted February 22, 2007 Share Posted February 22, 2007 What do you mean by filtering? Link to comment https://forums.phpfreaks.com/topic/39370-solved-need-serious-phpmysql-full-text-search-help/#findComment-191326 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? Link to comment https://forums.phpfreaks.com/topic/39370-solved-need-serious-phpmysql-full-text-search-help/#findComment-191338 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. Link to comment https://forums.phpfreaks.com/topic/39370-solved-need-serious-phpmysql-full-text-search-help/#findComment-191346 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); } Link to comment https://forums.phpfreaks.com/topic/39370-solved-need-serious-phpmysql-full-text-search-help/#findComment-191390 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.