I have search code that is below: - $term = $vbulletin->input->clean_gpc('r', 'term', TYPE_STR);
-
if ($term != ''){$term_db .= "AND f.field8 like '%$term%' OR f.field10 like '%$term%' OR f.field12 like '%$term%' OR f.field13 like '%$term%' OR f.field21 like '%$term%' "; }
The problem is:
The full text is "leonardo dicaprio"
If i search 'leo' or 'leonardo' or 'dicaprio' or 'leonardo dicaprio' is ok.
If change position or cut the words like if I search 'leo dicap' or dicaprio leonardo it won't show the result.
Can someone out there help me how to make it possible?
11 1588
search 'leo dicap' or dicaprio leonardo it cant show the result
I had to do this. I did it by seperating the words using strtok, then searching on the word 'chunks' as I called them.
Then you need to decide whether both chunks or only one has to be a hit
@code green
sory code green, i not clear what you mean, can you give an example.sory, i new in php
From the manual
strtok() splits a string into smaller strings (tokens), with each token being delimited by any character from token.
That is, if you have a string like "This is an example string" you could tokenize this string into its individual words
by using the space character as the token.
Then which each chunk issue a separate SELECT query - AND f.field8 like '%$chunk%
strtok() is one function I can never write free hand so again, example from the manual - string = "This is\tan example\nstring";
-
/* Use tab and newline as tokenizing characters as well */
-
$tok = strtok($string, " \n\t");
-
-
while ($tok !== false) {
-
echo "Word=$tok<br />";
-
$tok = strtok(" \n\t");
-
}
-
If I can find my code I will post but I am sure it is too fragmented across multiple functions to be much use.
Pretty awful if I remember
i have use this function but it still not too smart search..
if i search it just read the first word.
You can't mix AND and OR - AND f.field8 like '%$term%' OR f.field10 like '%$term%' OR f.field12 like '%$term%' OR f.field13 like '%$term%' OR f.field21 like '%$term%'
Brackets should be used - AND (f.field8 like '%$term%'
-
OR f.field10 like '%$term%'
-
OR f.field12 like '%$term%'
-
OR f.field13 like '%$term%'
-
OR f.field21 like '%$term%')
thanks code green, but the problem still same. do you have any idea to make the search result more smarter like os commerce (osc)
I reckom I am smarter than OS commerce ;-)
Could you redfine the problem and post relevant code
- $term = $vbulletin->input->clean_gpc('r', 'term', TYPE_STR);
-
if ($term != '')
-
{
-
$token = strtok($term, " ");
-
$term_db .= "AND f.field8 like '%$token%'";
-
}
the problem is :
if i search 'melaka'
the result are :
- Seri Costa Hotel Melaka
- Phiten Shop (Mahkota Parade) - Melaka
- Melaka Batik House (Noor Alfa)
- Melaka Art Store
but if i search 'melaka art'
the result still same because of it keep 'melaka' value.
how if i want the result just show
- Melaka Art Store
can u help me?
You need to use strtok() in a while loop as in the example I posted.
Then you can build up the query string in the while loop using OR, or query each part seperately - $term_db .= "AND f.field8 like'";
-
$tok = strtok($string," ");
-
$term_db .= "%$tok%".' OR ';
-
-
while ($tok !== false) {
-
$tok = strtok($string," ");
-
$term_db .= "%$tok%".' OR ';
-
}
-
hello code green,
i have try your code but my page appear blank. i cant use while method.can it possible to use 'for loop'? i have try 'for loop', that is no error but this method cant find any result.can you give me example if do in for loop?
hye...i already solve this problem by use this - $tok = strtok($term, " ");
-
while ($tok !== FALSE)
-
{
-
$toks[] = $tok;
-
$tok = strtok(" ");
-
}
-
while (list($k,$v) = each($toks))
-
{
-
$term_db .= "AND f.field8 like '%$v%'";
-
}
tq green code for your great idea!
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Adam Nørregaard |
last post by:
Hi,
I have this Mysql db:
id int(11) autoincremement prim. key
parentid int(11)
... etc .. (fields for a discussion board)
When parentid=0 then it is a new thread, otherwise it is a...
|
by: nortelsale |
last post by:
i have a site that allow people to post for sale, for rent info, I want
to have advanced search function that can search all the posting (in my
site) by zip code, and by certain miles say 10, 20...
|
by: aznach |
last post by:
Hello!
I have a shared hosting account at GrokThis.net and have a problem with
the module order of the Python search path.
I'd like to use django's svn trunk instead of the...
|
by: venugopalsripada |
last post by:
Hi,
I use imaplib to download emails from my AOL accounts. I have 6 accounts. I am recieving ('NO', ) as a return value for search(None, 'ALL') for one of the accounts while all other acocunts are...
|
by: jonathan184 |
last post by:
Hi I tried getting this to work through dreamweaver but it did not.
So i found a n example on the internet , i followed everything exactly the search script does not work. Could somebody help me...
|
by: Paul |
last post by:
Hello,
I'm having a CSS positioning problem and hope someone can help me out please?
If you take a look at this test page:
http://www.greenflagaward.org.uk/home/beta
In Safari 3.0 and...
|
by: preeti13 |
last post by:
hi friends please help me with my problem i have a code for search application it is searching one record from the data base at a time but i have so many records with that name but its not searching...
|
by: Mark |
last post by:
Hi All,
I am creating a music database for a friend and have run into a problem.
Within the ALBUM table, I wanted to store the ARTIST_ID rather than the
ARTIST_NAME. To do this, I intended to have...
|
by: ryan2345 |
last post by:
Hi,
I have made a search page in which the user enters the keywords to be searched separated with a comma. The code that i ve used works well but it is displaying the name of the user twice....
|
by: jaffarkazi |
last post by:
Hi
I have a search page. A user would select the search parameters from
various textbox, dropdowns, etc.
Now the user will click search and get a list of search results. This
is available in a...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |