ok so i made the typo corrections and that seemed to solve most of it, it now will properly search for one word and display the appropriate results.... but it is still not searching for more than one work correctly.... for example there is a city field in the database where one of the cities names is "prince albert".... if i search for either "prince" or "albert" it will find the record properly, but if i search for "prince albert" it gives the error message for couldnt execute query
here is the updated code:
<html>
<head><title>Page</title></head>
<?php
include("other.inc");
$connection = mysql_connect($host,$user,$password)or die ("couldn’t connect to server");
$db = mysql_select_db($database,$connection)or die ("Couldn’t select database");
$userinput = explode(" ","{$POST['criteria']}");
$query = "SELECT * FROM houses";
echo "success<br>";
if ("{$POST['criteria']}" == "")
{
echo "no search criteria entered.";
exit;
}
//in case they don't enter any text
else
{
$arraycount = count($userinput);
for ($i = 0; $i < $arraycount; $i++)
{
$query .= " where name like '%$userinput[$i]%'
or address like '%$userinput[$i]%'
or city like '%$userinput[$i]%'
or province like '%$userinput[$i]%'
or postalCode like '%$userinput[$i]%'
or phoneNum like '%$userinput[$i]%'
or altPhoneNum like '%$userinput[$i]%'
or description like '%$userinput[$i]%'
or grouping like '%$userinput[$i]%'
or lattitude like '%userinput[$i]%'
or longitude like '%$userinput[$i]%'";
}
}
echo($query);
/ Display results in a table /
$result = mysql_query($query) or die ("Couldn’t execute query.");
while ($row = mysql_fetch_array($result,MYSQL_ASSOC))
{
extract($row);
echo "$name<br>";
}
?>
and here is the results from the echo($query); command:
success
SELECT * FROM houses where name like '%prince%' or address like '%prince%' or city like '%prince%' or province like '%prince%' or postalCode like '%prince%' or phoneNum like '%prince%' or altPhoneNum like '%prince%' or description like '%prince%' or grouping like '%prince%' or lattitude like '%userinput[0]%' or longitude like '%prince%' where name like '%albert%' or address like '%albert%' or city like '%albert%' or province like '%albert%' or postalCode like '%albert%' or phoneNum like '%albert%' or altPhoneNum like '%albert%' or description like '%albert%' or grouping like '%albert%' or lattitude like '%userinput[1]%' or longitude like '%albert%'Couldn’t execute query.
you will notice that the lattitude column is not getting the userinput variable passed to it, but is instead just incrementing the array.... not sure what is happening here, thx for the help so far.... im hoping somebody can further help me, ive been at this for hours so far