Hey there, I want to do a simple search of one field on my database to see if it contains any items of a search string. For instance if I had the field Name, which contained:
Alice
Bob
Sarah
Wendy
and did a search for 'a'
I would get Alice, and Sarah returned to me. This is a snippet of code of how I was thinking of running it. Ive already got a variable named '$search_str' which is what the user inputs to search for
while ($row = mysql_fetch_array($result))
{
$dbvar = $row[$searchoption];
.............
//now I want to check $dbvar (which in this case will be all the rows of 'name') to see if it contains any instances of $search_str, and place the name into an array for outputting later
}
Ive had a look at string functions, but cant seem to find what Im looking for. Basically its a needle in a haystack scenario.
Problems you might want to think about - i dont want it to find Sarah twice just cus its got 2 a's.
Thanks for all your help, im sure this should be simple (checking to see if one string is contained in another) but I cant seem to find it anywhere.
Nick
P.S SOrry for cross posting this to the database forum as well