Search Results...... not quite correct

A

Anonymous

Guest
:oops:

Hi I hope you can help...... I have done an advisor search but the results I get arent exactly what i want.... if i put in "lancashire" in the search box it brings results back with everything that has "shire" in it "lan" in it etc....how do i define it so it just brings back people in "lancashire"....

here is my code

--------------------------------------------

<html>
<style type="text/css">

</style>

<body bgcolor="FF9422">
<a href="javascript:history.go(-1);">Go back to Search</a>
<p><font color="#FFFFFF"><b>The Intermediarys that are in Your Area Are Listed
Below...</b></font></p>
<p> </p>
<p>
<?php

mysql_connect (localhost, tony, tony);

mysql_select_db (intermediary);

if ($townorcounty == "")
{$townorcounty = '%';}

if ($county == "")
{$county = '%';}

$result = mysql_query ("SELECT * FROM members
WHERE (town LIKE '$townorcounty%'
OR county LIKE '$townorcounty%')
");

if ($row = mysql_fetch_array($result)) {

do {
print $row["name"];
print (" ");
print $row["town"];
print (" ");
print $row["county"];
print (" ");
print $row["tel"];
print (" ");
print $row["fax"];
print ("<p>");
} while($row = mysql_fetch_array($result));

} else {print "Sorry, no records were found!";}

?>
</p>
</body>
</html>
 
Try outputting your SQL statement to verify that its correct. You have the basic format, which is like this:
SELECT field_list FROM table_name WHERE (field LIKE '%search criteria%')

Make sure that you have a single percent sign on both sides of the criteria and none inbetween

Best of luck

Will
 
Back
Top