I have uninstalled xampp and reinstalled it. Still not getting the SQL results. Anyone have any ideas? I think it should work or at least get something other that the code echoed. Here is what I have now:
TrainginDataBaseSearch.php File
<!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>Search for a EmployeeTraining Record</title>
<meta name="keywords" content="HTML, CSS, PHP" /> </meta>
<link rel="stylesheet" type="text/css" href="TrainingDataBase.css">
</head>
<body>
<div align="center">
<p>
<img src="Images/dsHeaderLogo.png"
width="950" height="125">
<br>
<!-- SEARCH TRAINING RECORDS -->
<h1 align="center"><u><strong><font face="arial">Search for a EmployeeTraining Record</font></strong></u></h1>
</p>
<br>
<br>
<form action="SearchResults.php" method="post">
<h4> Please Select a Employee: </h4>
<select name = "employee">
<option value=" ">Select Employee</option>
<option value="34">John Doe</option>
<option value="66">Jane Doe</option>
</select>
<br>
<br>
<input type="submit" value="SHOW TRAINING REPORT ">
</form>
</div>
<br>
<center>
<a href="TrainingDataBaseAdd.php"><img src="Images/AddTrainingBtn.png" alt="Add New Person to DataBase" /></a>
</center>
<br>
<br>
<center>
<a href="TrainingDataBaseUpdate.php"><img src="Images/UpdateTrainingBtn.png" alt="Click Here to UPDATE a Training Record" /></a>
</center>
</body>
</html>
SearchResults.php File
<!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>EmployeeTraining Record Results</title>
<meta name="keywords" content="HTML, CSS, PHP" /> </meta>
<link rel="stylesheet" type="text/css" href="TrainingDataBase.css">
</head>
<body>
<div align="center">
<p>
<img src="Images/dsHeaderLogo.png"
width="950" height="125">
<br>
<!-- SEARCH TRAINING RECORDS -->
<h1 align="center"><u><strong><font face="arial">EmployeeTraining Record Results</font></strong></u></h1>
</p>
<br>
<br>
<?php
if($_POST['employee'])
{
$emp_id = $_POST['employee'];
$con = mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("training_db", $con);
$result = mysql_query("SELECT * FROM employee WHERE Emp_Id=$emp_id");
echo "<table border='1'>
<tr>
<th>Emp_Id</th>
<th>LastName</th>
<th>FirstName</th>
<th>Dept</th>
</tr>";
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['Emp_Id'] . "</td>";
echo "<td>" . $row['LastName'] . "</td>";
echo "<td>" . $row['FirstName'] . "</td>";
echo "<td>" . $row['Dept'] . "</td>";
echo "</tr>";
}
echo "</table>";
mysql_close($con);
}
else
{
echo '<form action="SearchResults.php" method="post">';
echo '<h4> Please Select a Employee: </h4>';
echo '<select name = "employee">';
echo '<option value=" ">Select Employee</option>';
echo '<option value="34">John Doe</option>';
echo '<option value="66">Jane Doe</option>';
echo '</select>';
echo '<br>';
echo '<br>';
echo '<input type="submit" value="SHOW TRAINING REPORT ">';
echo '</form>';
}
?>
</div>
</body>
</html>
This is driving me NUTS. Can someone tell me if the code is correct. I think if it's not I think it's real close but I can't get it to pull results from the training_db all I get when I try to pull a training record is
Emp_Id LastName FirstName Dept "; while($row = mysql_fetch_array($result)) { echo ""; echo "" . $row['Emp_Id'] . ""; echo "" . $row['LastName'] . ""; echo "" . $row['FirstName'] . ""; echo "" . $row['Dept'] . ""; echo ""; } echo ""; mysql_close($con); } else { echo '
'; echo '
Please Select a Employee:
'; echo ''; echo '
'; echo '
'; echo ''; echo '
'; } ?>
Someone please help. Thanks