# ---- Begin sample.html <html> <body> <form action=searchform.php method=GET> Search for: <p> First Name: <input type=text name=fname size=15 maxlength=15> <p> Last Name: <input type=text name=lname size=15 maxlength=15> <p> <input type=submit> </form> </body> </html> # ---- End sample.html # ---- Begin searchform.php <html> <body> <?php mysql_connect (<MySQLserver>, <username>, <password>); mysql_select_db (<dbname>); if ($fname == "") {$fname = '%';} if ($lname == "") {$lname = '%';} $result = mysql_query ("SELECT * FROM <tablename> WHERE fname LIKE '$fname%' AND lname LIKE '$lname%' "); if ($row = mysql_fetch_array($result)) { do { print $row["fname"]; print (" "); print $row["lname"]; print("<p>"); } while($row = mysql_fetch_array($result)); } else {print "Sorry, no records were found!"; } ?> </body> </html> # ---- End searchform.php