Search Results...... not quite correct

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

karma_killer
New php-forum User
New php-forum User
Posts: 7
Joined: Tue Aug 06, 2002 12:04 am

Search Results...... not quite correct

Postby karma_killer » Tue Aug 06, 2002 12:05 am

: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">
<!--
body { font-family: Arial, Helvetica, sans-serif; font-size: 14px; font-weight: normal; color: #000033}
font { font-family: Arial, Helvetica, sans-serif; font-size: 14px; font-weight: normal; color: #000033}
-->
</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>&nbsp;</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>

elitecodex
New php-forum User
New php-forum User
Posts: 68
Joined: Tue Jul 09, 2002 8:45 am
Location: East Coast, USA
Contact:

Postby elitecodex » Tue Aug 06, 2002 10:43 am

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


Return to “PHP coding => General”

Who is online

Users browsing this forum: No registered users and 1 guest