| | |||||
| ||||||||
| Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics. |
![]() |
| | LinkBack | Thread Tools |
| | THREAD STARTER #1 (permalink) |
| Soon to be RICHdoggie! Join Date: Jan 2005 Location: UK
Posts: 2,408
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | Fulltext mysql search? here is my mysql code: Code: SELECT * FROM pd_shops WHERE MATCH (name, description, keywords) AGAINST ('$q') ????: NamePros.com http://www.namepros.com/programming/125006-fulltext-mysql-search.html I have 1 entry in my db, that is "Casino Tropez". Supposedly, if you were to type in "Casino" it should pick up "Casino Tropez" in the name field, right? It dosen't Fulltext search page - www.theshutter.co.uk/poordoggie/search/index.php "Like" search page - http://www.theshutter.co.uk/poordogg.../indexlike.php Type "casino tropez" into them both. The like one will work, and the other one wont! MAKE SURE YOU SELECT "BOTH" INSTEAD OF "UK" OR "USA". I DON'T HAVE THE COUNTRIES LOADED YET...If I use the query: Code: SELECT * FROM pd_shops WHERE name LIKE '$q' Can anyone help me, please! ![]() Thanks Tom
Last edited by PoorDoggie; 09-19-2005 at 10:46 AM.
|
| |
| | #2 (permalink) |
| Pro Coder & Designer Join Date: Apr 2005 Location: Netherlands
Posts: 967
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | Code: SELECT * FROM pd_shops WHERE name LIKE '%$q%'
__________________ aween web development |
| |
| | THREAD STARTER #3 (permalink) |
| Soon to be RICHdoggie! Join Date: Jan 2005 Location: UK
Posts: 2,408
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | does! thanksIs there any way of: - ordering that by relevancy? - making the search terms bold? - searching more than 1 field? Thanks Tom Oh yea, and how would I time how long it took to execute that query? Thanks a lot for your time! |
| |
| | #4 (permalink) |
| Senior Member Join Date: May 2004 Location: France
Posts: 1,226
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | Did you try that ? SELECT * FROM pd_shops WHERE MATCH (name) AGAINST ('$q') or MATCH (description ) AGAINST ('$q') or MATCH (keywords) AGAINST ('$q') I can't remember if match use an AND or OR logic by default, and no time to check... |
| |
| | THREAD STARTER #6 (permalink) | ||||||||||||
| Soon to be RICHdoggie! Join Date: Jan 2005 Location: UK
Posts: 2,408
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
????: NamePros.com http://www.namepros.com/showthread.php?t=125006 So, If I have: "This casino is very good" and I searched for "Casino" I want to be able to single out "casino" in the description and make it bold: This casino is very good. | ||||||||||||
| |
| | THREAD STARTER #9 (permalink) | ||||
| Soon to be RICHdoggie! Join Date: Jan 2005 Location: UK
Posts: 2,408
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
????: NamePros.com http://www.namepros.com/showthread.php?t=125006 Sorry to keep troubling everyone, but I seem to have come across another problem. Lets say I want to search up all records with "$q" in them, but I also want to filter it by a country. So for instance... if the user selects UK, I want the database to search all records with the search term, and where the country is "UK", or "Both"... This code won't work: Code: SELECT * FROM pd_shops WHERE name LIKE '%$q%' OR description LIKE '%$q%' OR keywords LIKE '%$q%' AND country='uk' OR country='both' Thanks be to anyone who can help me, and has already helped me... ![]() Tom | ||||
| |
| | #10 (permalink) |
| NamePros Regular Join Date: Aug 2005
Posts: 214
![]() | You need to group your last 'or' statement, like so: Code: SELECT * FROM pd_shops WHERE name LIKE '%$q%' OR description LIKE '%$q%' OR keywords LIKE '%$q%' AND (country='uk' OR country='both')
__________________ OnlineGames.net |
| |
| | #11 (permalink) |
| NamePros Regular Join Date: Sep 2005
Posts: 471
![]() ![]() ![]() | <?php $query = "SELECT * FROM search where keywords like $serch ORDER BY hitid"; $array = mysql_query($query); $items = mysql_num_rows($query); if($items < 1){ die("nuttin");} else { echo " Your search returned $items results.";} while($sql = mysql_fetch_array($array)){ echo "<P><a href=\"".$sql['url']."\">".$sql['title']."</a><BR><HR>".$sql['discription']."</P>}"; ?> |
| |
| | THREAD STARTER #12 (permalink) | ||||||||
| Soon to be RICHdoggie! Join Date: Jan 2005 Location: UK
Posts: 2,408
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Thanks! ![]()
Code: SELECT * FROM pd_shops WHERE name LIKE '%$q%' OR description LIKE '%$q%' OR keywords LIKE '%$q%' AND (country='usa' OR country='both') ![]() Please help ![]() thanks Know what: scrap that - I won't have a countries thing at the moment... just base it all in UK. When I need to get another country I will get that ccTLD and just use that! woo! all sortedThanks for everyone's help... thanks a lot! | ||||||||
| |
| | #13 (permalink) |
| NamePros Regular Join Date: Aug 2005
Posts: 214
![]() | Group the rest of the where... Code: SELECT * FROM pd_shops WHERE (name LIKE '%$q%' OR description LIKE '%$q%' OR keywords LIKE '%$q%') AND (country='usa' OR country='both')
__________________ OnlineGames.net |
| |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Googlism - What does google think of you? | deadserious | The Break Room | 55 | 12-15-2005 10:09 AM |
| GP0.com Taking Offers | .X. | Domains For Sale - Make Offer | 4 | 08-16-2005 09:56 PM |
| Tutorial: Getting Started With MySQL (The Basics) | deadserious | Webmaster Tutorials | 3 | 04-18-2004 02:17 PM |