[advanced search]
 

Go Back   NamePros.com > Discussion > Web Design & Development > Programming

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.


Closed Thread
 
LinkBack Thread Tools
Old 09-19-2005, 09:41 AM   #1 (permalink)
Soon to be RICHdoggie!
 
PoorDoggie's Avatar
 
Join Date: Jan 2005
Location: UK
Posts: 2,390
316.50 NP$ (Donate)

PoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nice


Fulltext mysql search?

here is my mysql code:
Code:
SELECT * FROM pd_shops WHERE MATCH (name, description, keywords) AGAINST ('$q')
How come this dosen't work? I apparantly have a fulltext index on those 3 fields.

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'
and type "casino tropez" into the search bar it will find "Casino Tropez", but any squiffy searches won't come out, and it won't search each individual word either.

Can anyone help me, please!

Thanks
Tom

Last edited by PoorDoggie; 09-19-2005 at 09:46 AM.
PoorDoggie is offline  
Old 09-19-2005, 09:50 AM   #2 (permalink)
Pro Coder & Designer
 
xlusive's Avatar
 
Join Date: Apr 2005
Location: Netherlands
Posts: 964
101.50 NP$ (Donate)

xlusive is just really nicexlusive is just really nicexlusive is just really nicexlusive is just really nicexlusive is just really nice


Code:
SELECT * FROM pd_shops WHERE name LIKE '%$q%'
that should work.
__________________
Online Dragonball Game
xlusive is offline  
Old 09-19-2005, 10:05 AM   #3 (permalink)
Soon to be RICHdoggie!
 
PoorDoggie's Avatar
 
Join Date: Jan 2005
Location: UK
Posts: 2,390
316.50 NP$ (Donate)

PoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nice


does! thanks

Is 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!
PoorDoggie is offline  
Old 09-19-2005, 10:14 AM   #4 (permalink)
Senior Member
 
dgaussin's Avatar
 
Join Date: May 2004
Location: France
Posts: 1,294
85.60 NP$ (Donate)

dgaussin is a splendid one to beholddgaussin is a splendid one to beholddgaussin is a splendid one to beholddgaussin is a splendid one to beholddgaussin is a splendid one to beholddgaussin is a splendid one to beholddgaussin is a splendid one to behold


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...
dgaussin is offline  
Old 09-19-2005, 10:21 AM   #5 (permalink)
Munky Designs
 
Join Date: May 2005
Posts: 997
417.00 NP$ (Donate)

Albino is a jewel in the roughAlbino is a jewel in the roughAlbino is a jewel in the rough


to order by something, add "ORDER BY variable" on the end.

make the search terms bold? surely thats how you display it, in which case, use html tags <b></b>?
Albino is offline  
Old 09-19-2005, 11:03 AM   #6 (permalink)
Soon to be RICHdoggie!
 
PoorDoggie's Avatar
 
Join Date: Jan 2005
Location: UK
Posts: 2,390
316.50 NP$ (Donate)

PoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nice


Quote:
Originally Posted by dgaussin
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...
That could be a good idea actually, and that would get the order thing done too.
Quote:
Originally Posted by Albino
to order by something, add "ORDER BY variable" on the end.
I want to order by relevance of the search. Not by a variable...
Quote:
Originally Posted by Albino
make the search terms bold? surely thats how you display it, in which case, use html tags <b></b>?
How would I single out the search terms?

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.
PoorDoggie is offline  
Old 09-19-2005, 11:09 AM   #7 (permalink)
Senior Member
 
dgaussin's Avatar
 
Join Date: May 2004
Location: France
Posts: 1,294
85.60 NP$ (Donate)

dgaussin is a splendid one to beholddgaussin is a splendid one to beholddgaussin is a splendid one to beholddgaussin is a splendid one to beholddgaussin is a splendid one to beholddgaussin is a splendid one to beholddgaussin is a splendid one to behold


Tom, the fulltext engine on mysql allow to order by relevance. I currently work on that, I'll test tomorrow.
dgaussin is offline  
Old 09-19-2005, 11:10 AM   #8 (permalink)
Munky Designs
 
Join Date: May 2005
Posts: 997
417.00 NP$ (Donate)

Albino is a jewel in the roughAlbino is a jewel in the roughAlbino is a jewel in the rough


oops, sorry, i completely miss understood

worse thing is i cant help you
Albino is offline  
Old 09-19-2005, 11:31 AM   #9 (permalink)
Soon to be RICHdoggie!
 
PoorDoggie's Avatar
 
Join Date: Jan 2005
Location: UK
Posts: 2,390
316.50 NP$ (Donate)

PoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nice


Quote:
Originally Posted by dgaussin
Tom, the fulltext engine on mysql allow to order by relevance. I currently work on that, I'll test tomorrow.
Fulltext dosen't seem to work on any of my scripts/servers. I have 2 mysql servers, all of them seem to allow fulltext indexes (of which I have set up) but they don't seem to work.

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'
becasuse all results with "country='both'" come up regardless of weather they have the search term in them or not.

Thanks be to anyone who can help me, and has already helped me...

Tom
PoorDoggie is offline  
Old 09-19-2005, 12:57 PM   #10 (permalink)
NamePros Regular
 
Join Date: Aug 2005
Posts: 214
170.00 NP$ (Donate)

slantednet is on a distinguished road


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')
I believe the way you have it is saying "WHERE name LIKE '%$q%' OR description LIKE '%$q%' OR keywords LIKE '%$q%' AND country='uk' " -*OR-* "country='both'"
__________________
OnlineGames.net
slantednet is offline  
Old 09-19-2005, 01:31 PM   #11 (permalink)
NamePros Regular
 
Join Date: Sep 2005
Posts: 252
179.85 NP$ (Donate)

The_Inferno will become famous soon enoughThe_Inferno will become famous soon enough


<?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>}";
?>
The_Inferno is offline  
Old 09-19-2005, 02:35 PM   #12 (permalink)
Soon to be RICHdoggie!
 
PoorDoggie's Avatar
 
Join Date: Jan 2005
Location: UK
Posts: 2,390
316.50 NP$ (Donate)

PoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nice


Quote:
Originally Posted by The_Inferno
<?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>}";
?>
Wow... great idea - a hit list. Items are ordered by popularity! Thanks!

Quote:
Originally Posted by slantednet
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')
This still dosen't work. When "usa" is selected (and the query is:
Code:
SELECT * FROM pd_shops WHERE name LIKE '%$q%' OR description LIKE '%$q%' OR keywords LIKE '%$q%' AND (country='usa' OR country='both')
) then the results show UK results too.

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 sorted

Thanks for everyone's help... thanks a lot!
PoorDoggie is offline  
Old 09-19-2005, 02:54 PM   #13 (permalink)
NamePros Regular
 
Join Date: Aug 2005
Posts: 214
170.00 NP$ (Donate)

slantednet is on a distinguished road


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
slantednet is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Googlism - What does google think of you? deadserious The Break Room 55 12-15-2005 09:09 AM
AdultSearch.us Monsterman Adult Domains For Sale 3 06-11-2004 07:54 AM
What should a US Adult Search be going for? Monsterman Adult Domain & Site Reviews 0 06-10-2004 12:29 PM
Tutorial: Getting Started With MySQL (The Basics) deadserious Webmaster Tutorials 3 04-18-2004 01:17 PM

Site Sponsors
Advertise your business at NamePros

All times are GMT -7. The time now is 08:44 AM.


Powered by: vBulletin® Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0
Template-Modifications by TMS
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85