Hello, Im having trouble with creating page that will search a database for the values entered. I have a Search.php file that has this
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Payroll and Timesheet Management Website</title>
<link rel="stylesheet" type="text/css" href="styles.css"/>
</head>
<body>
<?php writeHeader(); ?>
<p>
<span class="pageheader">Search for an employee:</span>
<br />
</p>
<form action ="search_results.php" method="post">
<div class="left_side">
Search:<br/>
Query:<br/>
</div>
<div class="middle_cont">
<select name="searchType" id="type">
<option name="EmployeeFName" value="EmployeeFName">Employee Name</option>
<option name="EmployeeID" value="EmployeeID">Employee ID</option>
<option name="EmployeeDepartment" value="EmployeeDepartment">Department</option>
<option name="EmployeeTeam" value="EmployeeTeam">Team</option>
<option name="ManagerID" value="ManagerID">Manager</option>
</select>
<br/>
<input type="text" name="query" id="query" size="25"/><br/>
</div>
<p>
<br/>
<input type="submit" value="Search for Employee" class="button" />
</p>
</form>
</body>
</html>
and the SearchResult.php that will actually show the results as
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Payroll and Timesheet Management Website</title>
<link rel="stylesheet" type="text/css" href="styles.css"/>
</head>
<body>
<?php writeHeader(); ?>
<p>
<span class="pageheader">Search Results</span><br/>
<?php
if(empty($_POST['query']))
{
exit('Please Fill in What you want to Search. Click <a href=\"search.php\">here</a> to go back.</p>');
}
else
{
echo"<i>Your search for {$_POST['query']} had the following results:</i>";
checkLogin();
sqlConnect();
mysql_select_db("titans", $con);
$XX = "No Record Found";
$method=$_POST['searchType'];
$search=$_POST['query'];
$query = mysql_query("SELECT * FROM Employee WHERE $method = '$search'");
$result = mysql_query($query);
while ($row = mysql_fetch_array($query))
{
$variable1=$row["0"];
$variable2=$row["1"];
$variable2=$row["2"];
$variable3=$row["3"];
$variable4=$row["4"];
$variable5=$row["5"];
print (" $variable1, $variable2, $variable3,$variable4",$variable3);
}
//below this is the function for no record!!
if (!$variable1)
{
print ("$XX");
}
//end
}
?>
I have tried for a week now, and this project is due friday, Can someone help? (PLEASE)
what I am trying to do is just use the values from the search.php to search the database and make the searchResult.php echo out what it found. It will search a table named Employee with values: EmployeeName, EmployeeID, ManagerID, EmployeeDepartment, and EmployeeTeam. i.e if the user selects Employee ID from the menu, and types in an ID, it will search the table for that ID and then print that Employee row which has (EmployeeName, EmployeeID, ManagerID, EmployeeDepartment, and EmployeeTeam), and if they choose department then the result page will print out the Employees with in that department, and same with the Team option....Im Sure my searchResult.php is way wrong but can someone help?