View Single Post
  #1 (permalink)  
Old 08-18-06, 07:42 PM
9999 9999 is offline
Newbie Coder
 
Join Date: Jul 2006
Posts: 86
Thanks: 0
Thanked 0 Times in 0 Posts
Search script improvement

This piece of code searches the $info field of my delimited text file database:

PHP Code:

foreach ($file as $line => $data)

{
    list(
$month$day$year$info) = explode('|'trim($data) );
    if (
stristr($info$search))
    {
    echo 
$info;
    }

I have 3 Questions:

1) Lets say a person was searching for "John Smith" they could enter "John Smith" or "John" or "Smith" and it would work. I would like to improve my search so that if a person searched for "John Smith" it would also find results for "John T. Smth" or " John Q. Smith" etc. Is there an easy way to do this?

2) How can I sort the $year field?

3) For each record, the data in my $info is 2 or 3 sentences long. When the current script returns a result, there is only 1 space between sentences even though there are 2 in my database. Any suggestions on how I can fix this?

Thanks in advance
Reply With Quote