Search witin text.
am 11.02.2007 05:49:59 von Chris Carter
Hi,
I have to send results to the users based on their search. Have got a
combined serach option in which data is searched from two different fields
and based on the match the result is sent or an error message (quite
simple). Now I need to change this, the one column of data is from a VARCHAR
field and have to seach for a perticular text from another column that is
TEXT. So there could be data like "Apparel | Footwear | Toys | Watches". If
the data matches the "Toys" the result is sent. The issue I have is quite
simple, its not working. Is there anything special that needs to be done
with the TEXT column?
Please advice, many thanks.
Chris
--
View this message in context: http://www.nabble.com/Search-witin-text.-tf3207710.html#a890 7729
Sent from the Php - Database mailing list archive at Nabble.com.
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Search witin text.
am 11.02.2007 06:20:39 von Micah Stevens
Send your query out on the list. That would give us something to work
on. This should be very easy..
select * from tablename where column like '%$search%'
or something of that nature. What are you doing?
-Micah
On 02/10/2007 08:49 PM, Chris Carter wrote:
> Hi,
>
> I have to send results to the users based on their search. Have got a
> combined serach option in which data is searched from two different fields
> and based on the match the result is sent or an error message (quite
> simple). Now I need to change this, the one column of data is from a VARCHAR
> field and have to seach for a perticular text from another column that is
> TEXT. So there could be data like "Apparel | Footwear | Toys | Watches". If
> the data matches the "Toys" the result is sent. The issue I have is quite
> simple, its not working. Is there anything special that needs to be done
> with the TEXT column?
>
> Please advice, many thanks.
>
> Chris
>
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Search witin text.
am 11.02.2007 07:37:55 von Chris Carter
Thanks much ... this has been achieved now. However, there is another issue.
Say for example, the user wants to search 'Chriscarter' but puts into the
search field 'Chris Carter' how is it that I can take only the 'Chris' out
of the search string and present the matching searches from the database?
Any clue or link would be of great assistance.
Thanks again.
Micah Stevens wrote:
>
> Send your query out on the list. That would give us something to work
> on. This should be very easy..
>
> select * from tablename where column like '%$search%'
>
> or something of that nature. What are you doing?
>
> -Micah
>
> On 02/10/2007 08:49 PM, Chris Carter wrote:
>> Hi,
>>
>> I have to send results to the users based on their search. Have got a
>> combined serach option in which data is searched from two different
>> fields
>> and based on the match the result is sent or an error message (quite
>> simple). Now I need to change this, the one column of data is from a
>> VARCHAR
>> field and have to seach for a perticular text from another column that is
>> TEXT. So there could be data like "Apparel | Footwear | Toys | Watches".
>> If
>> the data matches the "Toys" the result is sent. The issue I have is quite
>> simple, its not working. Is there anything special that needs to be done
>> with the TEXT column?
>>
>> Please advice, many thanks.
>>
>> Chris
>>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>
--
View this message in context: http://www.nabble.com/Search-witin-text.-tf3207710.html#a890 8170
Sent from the Php - Database mailing list archive at Nabble.com.
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Search witin text.
am 11.02.2007 11:01:56 von Chris
you can use explode
from php.net:
>> array *explode* ( string $delimiter, string $string [, int $limit] )
Returns an array of strings, each of which is a substring of /string/
formed by splitting it on boundaries formed by the string /delimiter/.
If /limit/ is set, the returned array will contain a maximum of /limit/
elements with the last element containing the rest of /string/. <<
as delimiter you would use a space character in this case. for example:
the user input is $input = "Chris Carter";
now you can $split = explode(" ", $input);
so $split would be an array that contains ["Chris", "Carter"]
now you can persorm your search using $split[0] and/or $split[1]
;) I hope that's what you're looking for
Chris Carter wrote:
> Thanks much ... this has been achieved now. However, there is another issue.
> Say for example, the user wants to search 'Chriscarter' but puts into the
> search field 'Chris Carter' how is it that I can take only the 'Chris' out
> of the search string and present the matching searches from the database?
>
> Any clue or link would be of great assistance.
>
> Thanks again.
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php