NogDog,
It is exact. But it still doesn't work. Could you see if you see a problem with the code below.
Thank you.
<html>
<head>
<Title>Search Results</Title>
</head>
<body>
<h2>Search Results</h2>
<br>
<?php
$link = "<br><br><A HREF='searchbyname.html'>Click here to go back to the search page.</a>";
$LastName = trim($LastName);
if(empty($_POST['LastName'])){
echo "No search term given.";
echo $link;
exit;
}
//if(!LastName){
// echo "No search term given.";
// exit;
//}
$con = mysql_connect("localhost","user","mypassword");
mysql_select_db("mycontacts",$con);
$query = "select FirstName,LastName,CellPhone from contact WHERE LastName LIKE '%".$LastName."%'";
$result = mysql_query($query);
if(mysql_num_rows($result)==0){
echo "Sorry, no matching result.";
echo $link;
exit;
}
while ($record = mysql_fetch_assoc($result)){
while(list($fieldname,$fieldvalue) = each($record)){
echo $fieldname.":<b> ".$fieldvalue."</b><br>";
}
echo "<BR>";
}
?>
</body>
</html>