help creating a multi field php search form that gets data from mysql

I need some help fixing my form for some reason it does not work I can use a single text field for a search but, I cannot get more than one to work here is my code


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"

<html xmlns="">


<meta http-equiv="Content-Type" content="text/html; charset=iso-
8859-1" />

<title>Passport To Languages Search Filemaker</title>

<link href="default.css" rel="stylesheet" type="text/css" media="screen" />

<script language="javascript" type="text/javascript">



var sfield=document.getElementsByTagName('form')[0].elements[0];




if(!this.value){this.value='Enter your search term here'};







<h1>Passport To Languages Search FileMaker</h1>

<div class="maincontainer">

<form method="get" action="processform.php">

<input type="text" name="searchterm" title="Enter your search
term here" value="Enter your search term here"
class="searchbox" />

Patient Last Name:<input type="text" name="searchterm1" title="Patient Last Name" value="Enter your search term here"
class="searchbox" /><br>

Recipient ID:<input type="text" name="searchterm2" title="Recipient ID" value="Enter your search term here"
class="searchbox" /><br>

Phone Number:<input type="text" name="searchterm3" title="Phone Number" value="Enter your search term here"
class="searchbox" /><br>

Date of Service:<input type="text" name="searchterm4" title="Date of Service" value="Start Date"
class="searchbox" /><br>






<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"


// include MySQL-processing classes

require_once 'mysql.php';


// connect to MySQL

$db=new MySQL(array ('host'=>'','user'=>'','password'=>'',

$searchterm4 = date('Y/m/d', strtotime($searchterm4));

$result=$db->query("SELECT * FROM data WHERE (at_client_sn)='423' AND (at_claimant_first_name)='%$searchterm%' AND (at_claimant_last_name)='%$searchterm1%' AND (at_case)='%$searchterm2%' AND (at_claimant_phone_number)='%$searchterm3%' AND (at_date) =$searchterm4");


echo '<div class="maincontainer"><h2>No results were found. Go
back and try a new search.</h2></div>'."n";



// display search results

echo '<div class="maincontainer"><h2>Your search criteria
returned '.$result->countRows().' results.</h2>'."";

echo "<table border='1'><center>";
echo "<tr><th>Appointment#</th> <th>Date</th> <th>Time........</th> <th>Language</th> <th>Patient Name</th> <th>Interpreters First Name</th> <th>INTERPRETERS Last..Name</th> </tr>";


echo "<tr onclick=thisfunction();> <td>";

echo "<tr>";
echo "<td>" . $row['appointment_sn_text'] . "</td>";
echo "<td>" . $row['at_date'] . "</td>";
echo "<td>" . $row['at_time'] . "</td>";
echo "<td>" . $row['at_language'] . "</td>";
echo "<td>" . $row['at_claimant_first_name'] . "</td>";
echo "<td>" . $row['INTERPRETERSbyInterpreterSN::ir_first_name'] . "</td>";
echo "<td>" . $row ['INTERPRETERSbyInterpreterSN::ir_last_name'] . "</td>";
echo "<td>" . "<a href='display.php?id=".$row['appointment_sn_text']."'>Display</a>" . "</td>";
echo "</tr>";


echo "</table>";


catch(Exception $e){

echo $e->getMessage();




and mysql.php


// define 'MySQL' class

class MySQL{

private $conId;

private $host;

private $user;

private $password;

private $database;

private $result;

const OPTIONS=4;

public function __construct($options=array()){


throw new Exception('Invalid number of connection parameters');


foreach($options as $parameter=>$value){


throw new Exception('Invalid parameter '.$parameter);






// connect to MySQL

private function connectDB(){


throw new Exception('Error connecting to the server');



throw new Exception('Error selecting database');



// run query

public function query($query){


throw new Exception('Error performing query '.$query);


return new Result($this,$this->result);


public function escapeString($value){

return mysql_escape_string($value);



// define 'Result' class

class Result {

private $mysql;

private $result;

public function __construct(&$mysql,$result){




// fetch row

public function fetchRow(){

return mysql_fetch_assoc($this->result);


// count rows

public function countRows(){


return false;


return $rows;


// count affected rows

public function countAffectedRows(){


throw new Exception('Error counting affected rows');


return $rows;


// get ID form last-inserted row

public function getInsertID(){


throw new Exception('Error getting ID');


return $id;


// seek row

public function seekRow($row=0){


throw new Exception('Invalid result set offset');



throw new Exception('Error seeking data');






Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.


please see code below..

$result=$db->query("SELECT * FROM data WHERE at_client_sn='423' AND at_claimant_first_name LIKE '%$searchterm%' AND at_claimant_last_name LIKE '%$searchterm1%' AND at_case LIKE '%$searchterm2%' AND at_claimant_phone_number LIKE '%$searchterm3%' AND at_date ='$searchterm4'");

Open in new window

$result=$db->query("SELECT * FROM data WHERE at_client_sn='423' AND at_claimant_first_name LIKE '%$searchterm%' AND at_claimant_last_name LIKE '%$searchterm1%' AND at_case LIKE '%$searchterm2%' AND at_claimant_phone_number LIKE '%$searchterm3%' AND at_date ='$searchterm4'");

Open in new window

lostinfmlandAuthor Commented:
I tried that code and it does not work. It works if you limit just by a single field.
lostinfmlandAuthor Commented:
I mean if you remove all the other fields and just leave one their IE.
$result=$db->query("SELECT * FROM data WHERE  at_claimant_first_name LIKE ' %$searchterm%''");
I think your column at_client_sn is unique or not repeated try removing the condition at_client_sn and see wat happens

One more thing I noticed is you are using "AND" operator to get the results in the query...I am not sure if that is what you want to do. Since you want to expand your search as much as possible to get the results. And using AND operator you are limiting it. Try using OR ...

$result=$db->query("SELECT * FROM data WHERE at_claimant_first_name LIKE '%$searchterm%' OR at_claimant_last_name LIKE '%$searchterm1%' OR at_case LIKE '%$searchterm2%' OR at_claimant_phone_number LIKE '%$searchterm3%' OR at_date ='$searchterm4'");

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.