boolean search
| From: | jtjohnston | Date: | Tue, 06 Nov 2001 04:09:17 +0000 |
| Subject: | boolean search | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-14032@lists.php.net to get a copy of this message | ||
Hi,
I'm looking for a piece of code that can do a boolean search from an
<input type=text name=searchme>.
Therefore, if the user types "AND" it will perform boolean
<input type=text name=searchme value="john AND mary">
Anything available?
John
-------------------------------------------------------------------------------------------------------------------------
This is what I am doing so far:
$lien = mysql_pconnect("localhost","username","password");
mysql_select_db("database",$lien);
$news = mysql_query('select * from news_elsst01 where news_title like
"%'.$searchenquiry.'%" order by news_title desc');
$mycounter = 0;
while ($personne = mysql_fetch_object($news))
{
$mycounter++;
}
echo "\t<font color=blue face=\"arial,helvetica\" size=3><b>Your search
found $mycounter entries!</b></font>\n\t<hr>\n\n";
$news = mysql_query('select * from news_elsst01 where news_title like
"%'.$searchenquiry.'%" order by news_title desc');
while ($personne = mysql_fetch_object($news))
{
echo "<li><a
href=\"".$personne->news_filename."\"><font size=3
color=red
face=\"arial,helvetica\"><B>".$personne->news_title."</B></font></a>
(<font size=1 color=Blue face=\"arial,helvetica\">By:
".$personne->news_credit."</font>)<br><font size=2 color=black
face=\"arial,helvetica\">";
//substr($personne->news_intro, 0, 200) // letters
$words = explode(" ", $personne->news_intro); //words
for ($i = 0; $i <= 40; $i++)
{
echo "$words[$i] ";
}
echo " ...</font></a>\n\n";
}