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?
possible answers to your questions:
1. you could split the search-query, by using the whitespace. then you have to loop over the search-options, during the foreach loop:
2. instead of overwriting the same variables (list($month, $day, $year, $info)), you have to use them as an array. then use the sort() function to sort the array. This way you will have to double loop over your data, as you can't display for the search query an sort the array at the same time. then the year wouldn't be displayed ordered.
3. Do you mean newlines or just whitespace? if it's just whitespace, use the str_replace function to replace ' ' by ' ', then there should be no problem. if it's newlines, then i have no idea.
Greetz,
UnrealEd
__________________
"Good judgement comes from experience, and experience comes from bad judgement." - Fred Brooks
I adapted your code to fit my needs (such as: I replaced the ordered list with a $count variable because I didn't want the indentation), however, I have 3 Questions.
1) I am not real familar to patern matching etc. In the code you gave me, is it restrictive in any way? What I mean is that for some searches I get less results than I dowith using the stristr as I did earlier.
2) In my first echo line, I want to display the month, year and date associated with that record. I tried this:
1) I am not real familar to patern matching etc. In the code you gave me, is it restrictive in any way? What I mean is that for some searches I get less results than I dowith using the stristr as I did earlier.
Hm, actually it should do the same, even better. It splits the string on every whitespace and searches for every word, case insensitive.
Quote:
2) In my first echo line, I want to display the month, year and date associated with that record. I tried this:
Cause these variables are the ones from the previous loop. They contain always the same values after the last loop.
Okay, now it is showing different Months and Days but they don't correspond to the month and day field from the record in which it came. The year does not either. Also, in some cases, all the results are not returned.