Boolean Fulltext Search Demo
(PHP 4.0.6 and MySQL 3.23.33)

You can use this form to search the quotes database (small sample dataset).
The functions: funcs.mysql.boolean.php
A simple implementation: example.mysql.boolean.php
This implementation: form.mysql.boolean.php
Details on these functions: article.mysql.boolean.htm

Show all quotes

Enter a Boolean expression

'; // database connection // $db_host = 'localhost'; $db_user = 'username'; $db_pwd = 'password'; $db_connect = mysql_connect($db_host,$db_user,$db_pwd) or die(mysql_error()); // sql construction // require_once('funcs.mysql.boolean.txt'); $fulltext_key = get_fulltext_key($table_name,$db_connect); if(strlen($search_string)>0){ $sql = "SELECT id, author, content, \n" .boolean_sql_select( boolean_inclusive_atoms($search_string), $fulltext_key)." as relevance \n" ."FROM $table_name \n" ."WHERE \n" .boolean_sql_where($search_string,$fulltext_key)." \n" ."HAVING relevance>0 \n" ."ORDER BY relevance DESC \n"; }else{ $sql = "SELECT id, author, content, '0.0' FROM $table_name"; } // data query // $result = mysql_query($sql,$db_connect) or die(mysql_error()); $result_rows = mysql_num_rows($result); // get results // $output = " "; for($ith=0;$ith<$result_rows;$ith++){ $ir=mysql_fetch_row($result); $output .= " \n"; } $output .= "
id author content relevance
$ir[0] $ir[1] $ir[2] $ir[3]
\n"; if(strlen($search_string)>0){ // get user readable statement // $parsed_as = boolean_parsed_as($search_string); // display process // echo "
Input Statement
\n" ."

$search_string

\n" ."
Parsed As
\n" ."

$parsed_as

\n" ."
SQL Generated
\n" ."

".nl2br($sql)."

\n" ."
Query Results
\n" ."

$output

\n"; }else{ echo "
Input Statement
\n" ."

No search string specified, showing all entries (not the function default).

\n" ."
Query Results
\n" ."

$output

\n"; } echo ' '; ?>