I’ve been trying to create a basic search for my site. The whole site is run on a [really simple] include based code I made. The search only entails a collection of titles. Since I do not mind adding each entry into the search file myself, the best that I could come up with is something like this:
[code]search.html:
Search for=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
search.php:
<?php $s = $_POST["search"]; $terms = explode(" ", $s); for($i = 0; $i < count($terms); $i++){ if ( $terms[$i] == "term1" ) {echo "Phrase associated with phrase 1";} if ( $terms[$i] == "term2" ) {echo "Phrase associated with phrase 1
";} if ( $terms[$i] == "term3" ) {echo "Phrase associated with word 2
";} if ( $terms[$i] == "term4" ) {echo "Phrase associated with word 3
";} } ?>[/code]
This causes 1 problem though. If I were to search for “term1 term2” then the result would be a duplicate “Phrase associated with phrase 1”. How might I fix this, or, is there a better method of going about searching a simple list?
PS. I have come across many “search” codes but they are reliant on mysql which is something I don’t wish for it to be.