Hi Nik,
I've been trying like a week to get this thing to work. I've tried applying the code in different formats to no avail. The best result I get so far is a blank page. Below is the method I used in applying the code you posted earlier.
===================>>
<?
require_once("fns_lib.inc"); // my function library
//============ function to search multiple words ==================
function searchxp()
{
global $searchterm; // submitted from a form input field
// search for the search term
$searchterm = trim($searchterm);
//test for empty submissions
if (!$searchterm)
{
echo "No search term entered";
exit;
}
$terms = preg_split("/\s+/", $searchterm);
$where_clauses = array();
foreach ($terms as $term)
{
$where_clauses[] = "name like '%{$term}%'";
$where_clauses[] = "addr like '%{$term}%'";
$where_clauses[] = "state like '%{$term}%'";
}
$where_clause = "where" . join ("\n or ", $where_clauses);
if (!($conn = db_connect()))
return false;
$result = mysql_query( "select churchid, name
from list
'$where_clause' ");
if (!$result)
return false;
// Displays the list
$num_results = mysql_num_rows($result);
if ($num_results == 0)
{
echo "No record Found";
exit;
}
echo "<h4>[u]$num_results results found for $searchterm</u></h4>";
for ($i = 0; $i < $num_results; $i++)
{
$row = mysql_fetch_array($result);
echo "<span id=results>";
echo "<strong>";
echo htmlspecialchars(stripslashes($row["name"]));
echo "</strong>";
$name = $row["name"];
$churchid = $row["churchid"];
echo "</span>";
echo "<br>";
echo "</p>";
}
}
// ===== function ends here =========
searchxp(); // call to function
?>
============>>
This is my complete code, please let me know where I'm getting it wrong.
Thanks a lot
http://www.kephassolutions.com