G
Guest
Guest
Hi,
I would be very greatful if you could give me a little help with my php mysql search code.
The problem I have is that when i search a record in my table it will only search the first word. i.e. if the record is 'bob smith' and I search for 'smith' it won't find the record, when it would if I searched for 'bob'.
I'm sure it's something very simple - thanks.
Michael
UK
[Edit by swirlee: Added code tags. They're there for a reason, people -- use them!]
I would be very greatful if you could give me a little help with my php mysql search code.
The problem I have is that when i search a record in my table it will only search the first word. i.e. if the record is 'bob smith' and I search for 'smith' it won't find the record, when it would if I searched for 'bob'.
I'm sure it's something very simple - thanks.
Michael
UK
Code:
<html>
<body>
<font face="Verdana, Arial, Helvetica, sans-serif" size="1">
<?php
mysql_connect (localhost, eyeb, eye28);
mysql_select_db (eyeb);
if ($Type == "")
{$Type = '%';}
if ($Name == "")
{$Name = '%';}
$result = mysql_query ("SELECT * FROM Tourism
WHERE Type LIKE '$Type%'
AND Name LIKE '$Name%'
");
if ($row = mysql_fetch_array($result)) {
do {
print ("<i>");
print $row["Type"];
print ("</i>");
print ("<BR>");
print ("<B>");
print $row["Name"];
print ("</B>");
print ("<BR>");
print $row["Description"];
print ("<BR>");
print ("For booking call Tourist Information on (01271) 870553");
print ("<P>");
} while($row = mysql_fetch_array($result));
} else {print "Sorry, no records were found!";}
?>
</font>
</body>
</html>
[Edit by swirlee: Added code tags. They're there for a reason, people -- use them!]